Hi All,
I have a HTML web resource to launch the selected account form for account creation and other one is for load the account form on which the record is created.
But, the JavaScript web resource which is used to reopen the account record within the particular account form (in which created) is not working as expected.
Somehow it launch the incorrect form and the field which i am using to separate the form name is also get update.
Is there any way to not update a field once it has some value or Need to update the code?
Code is given below: -
function onLoad()
{
//if the form is update form
if (Xrm.Page.ui.getFormType()==2){
// variable to store the name of the form
var lblForm;
// get the value picklist field
var relType = Xrm.Page.getAttribute("new_formname").getValue();
// switch statement to assign the form to the picklist value
//change the switch statement based on the forms numbers and picklist values
switch (relType) {
case 'Site':
lblForm = "Site";
break;
case 'NoPileups - Site':
lblForm = "NoPileups - Site";
break;
case 'Account - Franchise':
lblForm = "Account - Franchise";
break;
case 'Distributor':
lblForm = "Distributor";
break;
case 'Organization':
lblForm = "Organization";
break;
case'Sage-Organization':
lblForm = "Sage-Organization";
break;
default:
lblForm = "Sage-Site";
}
//check if the current form is form need to be displayed based on the value
if (Xrm.Page.ui.formSelector.getCurrentItem().getLabel() != lblForm) {
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 == lblForm) {
//navigate to the form
item.navigate();
return;
} //endif
} //end for
} //endif
}
}//endif