Hi CRM World,
I am facing an issue with BPF. We have 3 status reasons: Progress, pending and resolved and we have 3 BPF stages respectively. I am writing java script on form load event so that based on the status reason i need to automatically change to respective BPF stage.
1. movenext() and moveprevious() works fine only when case is active. If case is resolved my java scripts throws an error. How to overcome this issue for resolved case. Tried using WebAPI calls inside java script, but still failed.
2. If i want to directly move from 1st BPF stage to 3rd BPF stage i am moving 2 movenext() consecutive statements. But only one of them is working (and to my surprise first statement returns invalid and next statement works fine). Is there any other way to achieve this?
Thanks in advance
*This post is locked for comments
Thanks Goutam for quick reply.But you script wont work in my case as when case is resolved the form becomes read only. When i try to update BPF stage it failed.
Workaround:
From Dynamics 365 8.2, we have a new feature where a new entity (with same name as BPF) is created for every BPF rule in CRM. If a case record is created, new record in the BPF entity will be created.
I have written OOB workflow and made changes to the associated BPF record. This will reflect my stage change in case record. (FYI since case is parent and associated BPF is child record we can create a lookup field on case form to point to associated BPF record thus accessing the related BPF record from case entity through lookup)
Hi ,
Try to call below code in the onload function.
function OnloadFormData() { Xrm.Page.data.process.addOnStageSelected(checkSelectedStagechange); }
Hi ,
May be you need to write the logic as per your requirement but below code may help you -
Its basically automatically click to next stage ,if the current stage and selected stage id is not same.
Xrm.Page.data.process.addOnStageSelected(checkSelectedStagechange); function checkSelectedStagechange() { var currentStageId = Xrm.Page.data.process.getActiveStage().getId(); //You need to write your logic here var selectedStageId = Xrm.Page.data.process.getSelectedStage().getId(); if (currentStageId != selectedStageId) { Xrm.Page.data.process.setActiveStage(currentStageId, MoveNextStageBPF) //Move next stage } } function MoveNextStageBPF() { var activeStage = document.querySelector(".processStageContainer.activeStage"); if (activeStage) activeStage.click() }
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156