RE: opening different form types
thanks, but i am facing an error when opening an existing opportunity.
the code is :
function OnLoadFormSelector() {
if (Xrm.Page.ui.getFormType() == 2) { // This will trigger only when Update form
var lblForm;
//THIS LINE IS GENERATING THE ERROR
var OPP_Type = Xrm.Page.getAttribute("hsc_originatingleadtype").getValue(); //Get the optionset value , replace the optionset field name
switch (OPP_Type) {
case "Restaurant Lead": // Replace the optionset value
lblForm = "Opportunity-form-1"; // Replace Form name based on optionset value
break;
case "Marketing Lead":
lblForm = "Opportunity-form-2";
break;
default:
lblForm = "Opportunity";
}
var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
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) {
if (itemLabel != formLabel) {
item.navigate();
}
}
}
}
}
}
and the error Is :
TypeError: Cannot read property 'getValue' of null
at OnLoadFormSelector (hungerstation-sb.crm4.dynamics.com/.../hsc_opportunity_form_selector_based_on_lead_type)
thanks.