Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Set Business Process Flow to Finished in a Workflow

(0) ShareShare
ReportReport
Posted on by 300

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Set Business Process Flow to Finished in a Workflow

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

  • Jeudy Molina Profile Picture
    Jeudy Molina 170 on at
    RE: Set Business Process Flow to Finished in a Workflow

    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

  • Verified answer
    mluce Profile Picture
    mluce 300 on at
    RE: Set Business Process Flow to Finished in a Workflow

    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);

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans