Hi Guys,
I've been working today on the following scenario:
We have 3 Case forms (each one for a different Case Origin Type)

On each form we have a JS that checks the case origin and based on the value changes the form for the user:
formSelector : used to get the list forms that are in the entity (only if more than 1)
getCurrentItem() : returns the current form rendered to the user (this is most important)
navigate() : it will help(force) to navigate to the form that's selecting
|
function _onLoad(){
if(Xrm.Page.ui.getFormType() == "2") //doing only on update mode, so only will get the Case Origin
{
var caseOrigin = Xrm.Page.getAttribute('caseorigincode').getValue();
var items = Xrm.Page.ui.formSelector.items.get();
var currentItem = Xrm.Page.ui.formSelector.getCurrentItem();
for (var it in items) //iterate all the items means forms
{
var form= items[it];
var formLabel = form.getLabel(); //get the form label like Email, Phone Call
//Check condition Label from Form and the corresponding Case Origin and mainly if its not the Current Selected Form
if (formLabel == "Phone Call" && caseOrigin == "1" && currentItem.getLabel() != "Phone Call")
{
form.navigate(); //now in this case just navigate
}
else if (formLabel == "Email" && caseOrigin == "2" && currentItem.getLabel() != "Email")
{
form.navigate();
}
else if (formLabel == "Information" && caseOrigin == "3" && currentItem.getLabel() != "Information")
{
form.navigate();
}
}
}
}
|

But when i load the form or change a value to case origin i get the following error:

This is the information from the log:
SyntaxError: Unexpected end of input
at RunHandlerInternal (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
at RunHandlers (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
at OnScriptTagLoaded (ORGNMAE.dynamics.com/.../ClientApiWrapper.aspx
at https://ORGNAME.dynamics.com/form/ClientApiWrapper.aspx?ver=1565753557:244:1

TypeError: Cannot read property 'Initialize' of undefined
at eval (eval at RunHandlerInternal (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx, <anonymous>:1:27)
at RunHandlerInternal (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
at RunHandlers (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
at OnScriptTagLoaded (ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
at ORGNAME.dynamics.com/.../ClientApiWrapper.aspx
Anyone has any suggestion where im mistaking?
Thanks in advanced and regards