{Code Tip} How to check Quick Create form type via JavaScript in D365 CE

In this blog post, we will learn how to check the Quick Create form type by using JavaScript. Quick-create forms are a convenient way to create new records without leaving the current page. 

Requirement

To perform logic or validation based on the form type, we need to get the form type value.

To distinguish between create and quick create forms, we can use JavaScript.  

In the present scenario, I will show how to create a contact from the Account entity using the quick create form and then Auto-populate the field ‘Job Title’ as ‘Developer’.  

Implementation:

  • To implement this requirement, we are using java script.
function GetFormType(excecutionContext)

{
//Get the form Context.
var formContext = excecutionContext.getFormContext();

//To get the Context object
var contextObject = excecutionContext.getContext();

//To get the form type via getQueryStringParameters()
var formType = contextObject.getQueryStringParameters().pageType;
//to check is available form is type Quick Create
if(formType == "quickcreate" && formContext.getAttribute("jobtitle") != null)
{
//To set the 'Job Title'
formContext.getAttribute("jobtitle").setValue("Developer");
}
}

Output:

Hope it helps! 

Power 365ing as usual! 

Any requirements, implementation or consulting work in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual? 

Problem Area – Technical, Functional, Training, Development or consulting? 

Me and my team are here to assist, please fill the following form for your business needs: Click here 

Leave a comment