Hi All,
I have used js to show form based on lookup field value,here am using case entity which has 6 types of main forms which are active there i have used switch case to show particualr form, it was working earlier but suddenly got stopped working same script code am using for all the forms on load.
Apart from this active 2 more forms are there but they are in InActive forms which i dont think the script has to be present.In UCI i can see only 6 main forms & am toggling based on field value.
Is anyone has any idea why its not working the below code am using :
//Show form based on Interaction Type, keep this method in all case forms
function showForm(executionContext) {
try {
var formContext = executionContext.getFormContext();
var interactionType = GetLookupName(formContext, "mdc_interactiontype");
var lblForm;
var relType = interactionType
switch (relType) {
case "Gift & Entertainment":
lblForm = "Case Overview - G&E";
break;
case "Conflict of Interest":
lblForm = "Conflict of Interest";
break;
case "Investigation":
lblForm = "Case Overview - Investigation";
break;
case "Enquiry":
lblForm = "Case Overview - Enquiry";
break;
case "Personal Trade Management":
lblForm = "Case Overview - Personal Trade Management";
break;
case "Restricted Security Management":
lblForm = "Restricted Securities";
break;
default:
lblForm = "Case Overview - G&E";
}
//check if the current form is form need to be displayed based on the value
var formLabel = formContext.ui.formSelector.getCurrentItem().getLabel();
if (formLabel != lblForm) {
var items = formContext.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();
}
}
}
} catch (error) {
var errorOptions = {
details: "Error in CaseOverviewEnquiry js, Method Name:showForm().Download Error log file",
errorCode: 2,
message: error.message
};
Xrm.Navigation.openErrorDialog(errorOptions);
}
}
Thanks,
Jharana