I have 4 different forms in Account entity. Based on the form one field gets updated. Nevertheless every time that I open an existing record that was created using certain form it opens the record based on my last viewed form.
Example :
I create Company "Blue" using form A and I save my record.
Then I create company "Green" using form B and I save the record.
If I go back to the first company it gets opened but it shows form B instead of form A
And this is my function to default a field value based on the form......
function changeFormLoad() {
var formType = Xrm.Page.ui.getFormType();
var formItem = Xrm.Page.ui.formSelector.getCurrentItem();
var formLabel2 = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
var companyClassification = Xrm.Page.getAttribute("randgrp_changingformname");
if (formType == 1) {
switch (formLabel2) {
case "Form_test_one":
var field = Xrm.Page.getAttribute("randgrp_changingformname").setValue("Es la forma1");
break;
case "Test_form_two":
Xrm.Page.getAttribute("randgrp_changingformname").setValue("Es la forma2");
break;
case "Test_form_three":
Xrm.Page.getAttribute("randgrp_changingformname").setValue("Es la forma3");
break;
default:
alert("test");
}
}
}








