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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

refreshing UI of dynamc form getting in loop or error

(0) ShareShare
ReportReport
Posted on by 410

Hi All, 

I am trying to lock fields when the NEXT button in a BPF is clicked, I have used the code below, but i found out it only works when you refresh the form. I tried using the code in an onsave event, but i get the pop up that the form isnt saved and even when i click okay, it clears out the form and when i put the code inside the addOnStageChange event of the BPF, he form gets into a loop. Someone help me out, as this looks petty but yet wouldnt work-

function Lockfields(executionContext) {
var formContext = executionContext.getFormContext();

var appRequest = formContext.getAttribute("approval");
if (appRequest != null) {
if (appRequest.getText() == "draw") {
//lock fields
  formContext.getControl("field").setDisabled(true);
  formContext.getControl("field").setDisabled(true);
  formContext.getControl("field").setDisabled(true);

Xrm.Page.data.save().then(Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()));

    }
   }
}

In Between: How do i paste codes on here, since the change of the UI, i cant paste in a code editor?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi,

    I'm assuming you have approval field on certain bpf stage and you want to lock other fields. Based on value in approval field.

    Create one onload function.and add stage change event.

    Then add your function in "formContext.data.process.addOnStageChange(LockFields)".

    And remove "Xrm.Page.data.save().then(Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()));".

    Replace "appRequest.getText() == "draw"" with "appRequest.getText() === "draw"".

    You might also want to do same on stage selection i.e.

    formContext.data.process.addOnStageSelected(LockFields);

    Regards,

    Ketan

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans