CRM 2011: JavaScript – Check if FormType is “Create” or “Edit”

To check the type of opened form in CRM 2011, we use the following code:

var formType = Xrm.Page.ui.getFormType();

The line of code above returns an int.

A value of 1 means the form is of type “Create” while a value of 2 means that the form is of type “Edit/Update”.

var formType = Xrm.Page.ui.getFormType();
if (formType != undefined){
    if (formType == 1) { //if form is of type "Create"
        //Perform Create Form Logic
    }
    else if (formType == 2){
        //Perform Edit Form Logic
    }
}

Leave a Reply