web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Lock a field in Business Process Flow

(1) ShareShare
ReportReport
Posted on by 50

Hi,

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.

I have the same question (0)
  • Verified answer
    indyanin Profile Picture
    60 on at

    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 = formContext.data.process.getActiveStage().getId();

       // disable your field

       formContext.getControl(logicalNameOfYourField).setDisabled(true)

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

       if (activeStageId === idOfyourStage) {

           formContext.getControl(logicalNameOfYourField).setDisabled(false)

       }

       // 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

       formContext.data.process.addOnStageChange((ctx) => {

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

           }

       }

    Hope this helps.

    Regards,

    Konrad

  • Verified answer
    Nya Profile Picture
    29,060 on at

    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’.

    4532.png

    1. Create a Web Source.

    0820.png

    The Script is:

    function setNum(){
    
        Xrm.Page.getControl("header_process_new_num").setDisabled(false);
        Xrm.Page.getControl("header_process_new_num_1").setDisabled(true);
    
    // 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.

    6558.png

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

    4278.3_2D00_1.png

    1325.3_2D00_2.png

    Hope this helps.

    Best Regards,

    Nya

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans