web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Set Business Process Flow to Finished in a Workflow

(0) ShareShare
ReportReport
Posted on by 306

Hi,

I have a requirement to set a Business Process Flow to 'Finished' in a workflow but cannot find any way to do it.  The business reason is that a manager needs to be able to "complete" a load of records at once via a workflow.

Is this possible?  If not.. is it possible in code via an action, and if so how?

Thanks for any pointers.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    mluce Profile Picture
    306 on at

    I have managed to do this with a custom action and this code;

                var targetApplication = (EntityReference)context.InputParameters["Target"];
                var record = localcontext.OrganizationService.Retrieve(targetApplication.LogicalName, targetApplication.Id, new ColumnSet("processid"));
                var cleanProcessid = ((Guid)record["processid"]).ToString().Replace("-", "");
                var processFlowEntityName = "reg_bpf_" + cleanProcessid;
                var fieldName = "bpf_" + targetApplication.LogicalName + "id";
    
                var bpfInstanceRecord = CrmHelper.GetBpfInstance(localcontext, processFlowEntityName, fieldName, targetApplication.Id.ToString());
    
    
                var stateRequest = new SetStateRequest
                {
                    EntityMoniker = new EntityReference(processFlowName, (Guid)bpfInstanceRecord["businessprocessflowinstanceid"]),
                    State = new OptionSetValue(1), // Inactive.
                    Status = new OptionSetValue(2) // Finished.
                };
                context.OrganizationService.Execute(stateRequest);
  • Jeudy Molina Profile Picture
    172 on at

    Hi @mluce, could you please share the steps to create this action? I tried to do it but I am not able to make it work properly

  • Community Member Profile Picture
    on at

    Hi @mluce, can you please post the code of the function "GetBpfInstance"?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans