CRM2011-MultiForm: Display default form based on the Optionset/Lookup field values on the form.
var programlookup = new Array();
programlookup = Xrm.Page.getAttribute("msft_programid").getValue();
if (programlookup != null)
{
var name = programlookup[0].name;
var guid = programlookup[0].id;
var entType = programlookup[0].entityType;
// alert(Xrm.Page.ui.formSelector.getCurrentItem().getLabel());
if (Xrm.Page.ui.formSelector.getCurrentItem() != null)
{
var formlabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
if (formlabel != name)
{
var items = Xrm.Page.ui.formSelector.items.get();
for (var i in items)
{
var item = items[i];
var itemId = item.getId();
var itemLabel = item.getLabel()
if (itemLabel == name)
{
var attributes = Xrm.Page.data.entity.attributes.get();
for (var j in attributes)
attributes[j].setSubmitMode("never");
item.navigate();
}
}
}
}
}
Disadvantages:
1. Performance(Form will load twice if last opened form is not same as field value)
2. On load page will blink
3. Make optionset/lookup field readonly so that user can't change the values
No comments:
Post a Comment