Posts

Showing posts from July, 2019

Prevent User moving BPF next stage or Set current stage Active based on Sub-grid record count or any type condition in Dynamics 365

Image
Sometimes we may have requirement to prevent BPF stage to set active or move next stage based on some condition. Here I want to describe similar kind of requirement , let say I am  in opportunity  stage called “Develop” , I want to validate one  subgrid in the form which having at least one record when user click on “Next Stage” or “Save” or “Set Active” one . If the record count = 0 then stage will not move forward and not been saved. You may use this concept to validate  any field value or  some custom logic. Here is few high level  steps – Copy below scripts in a JavaScript web resource. Replace the stage name and subgrid name and don’t forget to replace double comma with double quote. function ValidateSelectedStageOnSave(context) { var result = true; // Get current stage name var stageName = Xrm.Page.data.process.getSelectedStage().getName().toString().toLowerCase(); if (stageName == "develop" ) {  // Need to replace the stage name which you want to valida