RE: How To Stop/Pause/Prevent "Previous Stage" Button on Business Process Flow Using Supported Way
Hi Kyi,
Sure, so here's the following instructions/highlights on what you can do -
1. The record you run on can have a Stage Name field (previously, this existed but was recently deprecated). To work around this problem on what Stage the record is, follow this blog of mine - d365demystified.com/.../bpf-process-stage-name-not-populating-on-records-in-d365-v9-deprecated-and-workaround
2. So let's say, you have the field correctly working on the record in terms of storing the stage name mentioned in the blog in #1 above.
3. Write a plugin on post-operation of the record. This should be a synchronous plugin because you want to throw error to the user on screen. The filtering attribute for the plugin registration step will be the stage name field mentioned in the blog.
4. When the plugin runs, check in context what was the Stage Name was changed to - i.e. "Stage A" or "Stage B", then check in pre-Image, if the value of that field was "Stage C" - this means you want to restrict the user now.
5. Once the point in #4 above holds true, throw an exception using throw new InvalidPluginExecutionExection("Sorry, you cannot move back to " + Stage Name (from the context));
Now, because this is a synchronous plugin, the record will not be saved even if it is registered in the post image if it correctly captures your exception.
Also, even if someone tries to change the name from the back-end, the plugin will work as opposed to JS that can only work on form.
I really hope this helps you. Pardon me for being short and on a high level of approach.
Thanks!