Skip to main content

Dynamics V9 Set Field Requirement Level JavaScript

Quick reusable JavaScript function for setting the requirement level of a field.

The below sets the requirement level for a single field called new_myfieldname to required.

function setRequirementlevel(executionContext)
var formContext = executionContext.getFormContext();
//Requirement levels available are
var level ="required";

Or if you want to set the levels of multiple fields at the same time

//Fields to set requirement levels
var fields = [
["firstname","none" ],
["lastname","none" ],
["fullname","none" ],
["fullname1","none" ],
["emailaddress1","required" ],
["telephone1","none" ],
["address1_line1","none" ],
["address1_postalcode","none" ],
["address1_country","none" ],
["address1_city","none" ]
var formContext;
//call this function
function setRequirementLevel( executionContext)
//get formcontext
formContext = executionContext.getFormContext();
//run the set level function for each field


function setLevel(item)


Charles Osei

Dynamics 365 Consultant @ Hitachi MCSE Business Applications Computer Science – University of Lincoln 2017 Nottingham D365/CRM user group Chapter Leader TDG – Community leader Twitter @charlied3v LinedIn

Leave a Reply