lock & unlock fields in D365 Introduction:

Now the task is if the summer field was null and automatically the winter field need to be locked or disabled,  if the summer field have any data the winter field need to be unlocked.

Lock & unlock

Now Create a new web resource and add the below code

function lockunlock(executionContext){
    var formContext=executionContext.getFormContext();
    var lock = formContext.getAttribute(“vinay_summer”).getValue();
    if(lock == null){
        formContext.getControl(“vinay_winter”).setDisabled(true);
    }
    else{
        formContext.getControl(“vinay_winter”).setDisabled(false);
    }
};

Add the Web resource to the Summer Field Properties

Now test it in the App

Its working,

  1.  summer field null

2.. Summer field have data