Hi,
We are on premise 2016 Dynamics 365. We have an issue where we are unable to move the business process on to the next stage. It will not set as active, as below;
*This post is locked for comments
Hi,
We are on premise 2016 Dynamics 365. We have an issue where we are unable to move the business process on to the next stage. It will not set as active, as below;
*This post is locked for comments
You can set them via the SDK within a console application. You'd need to retrieve the associated BPF record to your entity and then set the stageid to the coresponding stage name. Something like the snippet below :
using System; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Client; using System.ServiceModel.Description; using Microsoft.Xrm.Sdk.Query; using Microsoft.Xrm.Sdk; using System.Collections.Generic; using System.Configuration; using Microsoft.Xrm.Tooling.Connector; namespace BPFConsoleProject { class Program { static void Main(string[] args) { //Where Applies, replace with your values string userName = "username@domain.com"; string password = "password"; string authType = "AD"; string url = "crmserver:port/orgName"; Guid recordToFixId = Guid.Parse("record Guid on which the bpf is broken"); string recordToFixEntityName = "name of the entity against which the bpf is configured"; string businessProcessFlowName = "name of your bpf"; Guid stageToSetId = Guid.Parse("Guid of the stage name you want to set"); try { using (CrmServiceClient crmSvc = new CrmServiceClient($"UserName={userName};Password={password};AuthType={authType};Url={url}")) { if (!crmSvc.IsReady) throw new Exception($"Unable to connect to CRM Organization Error: {crmSvc.LastCrmError} \n {crmSvc.LastCrmException}"); // 1. Retrieve the Active Business Process Instance set against the records RetrieveProcessInstancesRequest retrieveProcessInstancesRequest = new RetrieveProcessInstancesRequest { EntityId = recordToFixId, EntityLogicalName = recordToFixEntityName }; RetrieveProcessInstancesResponse retrieveProcessInstancesResponse = (RetrieveProcessInstancesResponse)crmSvc.Execute(retrieveProcessInstancesRequest); Guid activeProcessInstaceId = new Guid(retrieveProcessInstancesResponse.Processes.Entities[0].Id.ToString()); Console.WriteLine("Active Process stage is: " + retrieveProcessInstancesResponse.Processes.Entities[0].Attributes["processstageid"].ToString()); EntityReference bpfReference = (EntityReference)retrieveProcessInstancesResponse.Processes.Entities[0].Attributes["processid"]; Entity processEntity = crmSvc.Retrieve(businessProcessFlowName, activeProcessInstaceId, new ColumnSet(true)); processEntity["activestageid"] = new EntityReference("processstage", stageToSetId); crmSvc.Update(processEntity); Console.Read(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
hope this helps
Radu
Hey,
Firstly, thank you so much for helping me.
They do not appear to match as would expect, how can I resolve this?
Can you check the stageid and the stagename against the record and see if there is any mismatch there ?
Hi Kokulan,
No errors or breaks when I set the stage.
Could you please check your Dev tool console (F12) to see if it logs any errors when you try to set the stage?
Hi Radu,
We have no custom JavaScript Running;
Thank you
Hello,
Do you have any logic around the business process flow (JavaScript, Plug-ins, etc.) ? If yes - if you disable them does it work?
I've seen this type of behavior in the past also when the stageid and the stagename on the form were not set correctly (stageid belonged to the wrong stagename of the business process flow) - this in generally was caused by custom javascript / plugins
Hope this helps,
Radu
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,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156