Hi Mahadeo,
I am admittedly a bit limited in my ability to write js, but the code I'm using is below:
function jpe_showForm() {
//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("leadsourcecode").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 1:
lblForm = "Lead Form 1";
break;
case 2:
lblForm = "Lead Form 2";
break;
default:
lblForm = "Default Lead";
}
// Current form's label
var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
//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) {
//Check the current form is the same form to be redirected.
if(itemLabel != formLabel) {
//navigate to the form
item.navigate();
} //endif
} //endif
} //end for
} //endif
} //endif
} //end function
It works, although it loads the default form and then reloads to the correct form. I'm not sure if there is any way to avoid this?