How to Set Field Requirement Based on Form Type in Dynamics 365 | JavaScript Tutorial – YouTube

Manish chauhanYouTube3 weeks ago50 Views



In this video, learn how to use JavaScript in Dynamics 365 CRM to dynamically set a field as required during the OnLoad event of a form. We demonstrate how to check if the form type is ‘Create’ and make the field mandatory while keeping it optional for other scenarios. Enhance your Dynamics 365 customization skills with this step-by-step tutorial!
Code-   function setFieldRequiredOnCreate(executionContext) {
    // Get the form context
    var formContext = executionContext.getFormContext();
 
    // Check the form type (Create = 1)
    if (formContext.ui.getFormType() === 1) {
        // Set the field as required
        formContext.getAttribute(“your_field_name”).setRequiredLevel(“required”);
    } else {
        // Set the field as not required
        formContext.getAttribute(“your_field_name”).setRequiredLevel(“none”);
    }
}
 
This video consists of:
00:00-00:20 Introduction
00:20-01:12 Use case
01:12-03:33 JavaScript code Writing
03:33-04:38 Web Resource Upload and add JS on load event 
04:38-05:36 Testing the code

#microsoftsoftware #microsoft #dynamics365 #microsoftdynamics365 #microsoftdynamics365businesscentral #techtutorial #tutorial #dataverse #dynamics365crm #javascript #javaprogramming #powerapps #powerautomate #javatutorial #javascripttutorial #test #java

source

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
February 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28   
« Jan   Mar »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...