• Home
  • Blog
  • About Me
  • Home
  • Blog
  • About Me
Dynamics 365

Setting Field Visibility when the Business Process Stage Changes

By Joe Gill  Published On 18th January 2015
In Dynamics 2015 we can now hook into the OnStageChange event which gets fired when the stage of a business process flow changes. We do this by adding an event handler to the OnStageChange event when the form loads. In this example when the form loads it calls the AddStageHandlers function so that the StageChangedHandler function gets called when the stage changes.

Dynamics CRM Form

When the StageChangedHandler function runs it checks if the opportunity is at the “Close” stage. If the stage is Close then the header field estimated value field is disabled so that the Estimated Revenue cannot changed. It also hides the purchase timeframe field.

  1. function AddStageHandlers() {
  2.     Xrm.Page.data.process.addOnStageChange(StageChangedHandler);
  3. }
  4.  
  5. function StageChangedHandler() {
  6.     var activeStage = Xrm.Page.data.process.getActiveStage();
  7.     var stageName = activeStage.getName();
  8.     if (stageName == “Close”) {
  9.         Xrm.Page.ui.controls.get(“purchasetimeframe”).setVisible(false);
  10.         Xrm.Page.ui.controls.get(“header_estimatedvalue”).setDisabled(true);
  11.     }
  12. }

Dynamics CRM Opportunity


Leave A Reply Cancel reply

You must be logged in to post a comment.

CRM Queue with a Office 365 Shared Mailbox
Previous Article
Maintaining Team Membership in Private Queues with a Plugin
Next Article