Skip to main content
Dynamics 365 general forum

Lock a field in Business Process Flow

editSubscribe (1) ShareShare
Posted on by 50


I defined 4 stages of Business Process Flow for an entity and i have a field that has to be enabled in the first stage and disabled in all the other stages.

Can anyone suggest of how could i achieve this.

Thank you.

  • Verified answer
    Nya Profile Picture
    Nya 29,043 on at
    RE: Lock a field in Business Process Flow

    Hi, Priya

    You can add a JavaScript into the form to control it.

    For example, I have a field ‘num’ in Contact entity. There are two stages in my BPF. Both of them contains ‘num’.


    1. Create a Web Source.


    The Script is:

    function setNum(){
    // The numbers of suffixes are incremented by Stage, the second stage is _1, the third one is _2

    2. Add the script to the form which executes the BPF. Set as an on-load event.


    3. Refresh the page of the form. You’ll see the different availability of ‘num’ in different stages.



    Hope this helps.

    Best Regards,


  • Verified answer
    indyanin Profile Picture
    indyanin 60 on at
    RE: Lock a field in Business Process Flow

    Hi Priya,

    The only way to do this as far as I'm concerned to use custom JavaScript on Form Load. First, you have to get GUID of your BPF and check its GUID then you have to check GUIDs of each stage via web API. when you have the id of your at which you want to enable that field you need first disable it likes so:

    function onLoad(ctx) {

       const formContext = ctx.getFormContext();

       const idOfyourStage = '<your stage id here>';

       const logicalNameOfYourField = 'header_process_<your field logical name>';

       //  gets current Active Stage Id

       const activeStageId =;

       // disable your field


       // check if id of a stage is where you should unlock that field

       if (activeStageId === idOfyourStage) {



       // Here you need to basically duplicate your logic, as the code above works on page refresh. When the user changes BPF stage, the code below will run => {

    // duplicate code above to run on each BPF stage update



    Hope this helps.



Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…


Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,068 Super User

Martin Dráb Profile Picture

Martin Dráb 222,591 Super User

nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans