HOW TO GET MICROSOFT DYNAMICS 365 FORM TYPE IN JAVASCRIPT

When working with forms, you have the ability to create different types of forms based on your needs : Main Form, Quick View Form, Quick Create Form, or Card Form.
Form type 0

The most common type is the Main Form which is the form where most of time the users work. The main form itself has different status that represents specific functionality or use, this is known as well as form type .

The purpose of this post is to know what are the different types of the Main form and how to get it using JavaScript, so you will have the ability to change its behavior based on its type that will be reflected for end users.

Getting the type of form can be done in JavaScript using the function formContext.ui.getFormType().

The following JavaScript function will display a popup message with the form type:

function getFormType(context) {
var formContext = context.getFormContext();
var formType = formContext.ui.getFormType();
var messageToDisplay = "";
switch (formType) {
case 1:
messageToDisplay = "Create / Quick Create form";
break;
case 2:
messageToDisplay = "Update form";
break;
case 3:
messageToDisplay = "Read Only form";
break;
case 4:
messageToDisplay = "Disabled form";
break;
case 6:
messageToDisplay = "Bulk Edit form";
break;
default:
messageToDisplay = "Undefined form";
}
var alertMessage = { text: messageToDisplay };
Xrm.Navigation.openAlertDialog(alertMessage, null);
}

form type 1

form type 2

The below table lists the different Dynamics 365 form types and their respective JavaScript return values:
Type: Number
Description: Form type. Returns one of the following values

ValuesForm type
0Undefined
1Create / Quick Create
2Update
3Read Only
4Disabled
6Bulk Edit


Hope This Helps!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT