Got it to working .... Thanks for providing help.
The only minor thing is that the original form loads first before the script loads the right one. - Looks like a little refresh all the time when loading a record.
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("new_campaignmode").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 = "Campaign Main";
break;
case 2:
lblForm = "Campaign Individual";
break;
default:
lblForm = "Campaign Main";
}
// 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