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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Business Process Flow ...
Power Apps
Unanswered

Business Process Flow programatically get Steps of Active Stage

(0) ShareShare
ReportReport
Posted on by 17

Hi,

 

I'm wondering if there's a good way to get all the steps in a Business Process Flow for the Current Active Stage using C# or even Web Api (pretty much without using client side logic like JavaScript).

 

I've seen that you can use RetrieveActivePath and RetrieveProcessInstances using this sample (https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/sample-work-business-process-flows) to get the current active stage but I'm not sure where to go from here to get the actual steps on this stage.

 

Any ideas would be much appreciated.

I have the same question (0)
  • ChrisPiasecki Profile Picture
    6,422 Most Valuable Professional on at

    Hi @Po5,

     

    The ClientData attribute of the ProcessStage entity will have the step information.

    If using the web api, you can fetch this as such:

    /api/data/v9.1/processstages?$select=stagename,clientdata&$filter=processid/workflowid eq <BpfWorkflowId>

     

    If using the C# SDK, you can simply just Retrieve the ProcessStage. Make sure you include the ClientData column in your columnset.

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

     

     

  • Po5 Profile Picture
    17 on at

    Hi @ChrisPiasecki,

     

    Thanks for that, but it looks like the ClientData gets me the steps of every stage in the BPF and I'm not sure how to distinguish whether they're in the current stage or not.

    All I can see that may be helpful is a DisplayLabelId (other than that I get DisplayName, Type, Field which has AttributName and IsRequired), which I'm not sure I can use to determine if it's in the current active stage.

    I feel like theres one more missing step here but not sure what it is yet.

     

    Cheers

  • ChrisPiasecki Profile Picture
    6,422 Most Valuable Professional on at

    Hi @Po5,

     

    You can retrieve the active stage id your record is on by querying the table for your BPF, filtering by the row ID of your primary table. You can then use that ID to query the process stages and filter by it.

     

    Have a review of the docs below on how to work with BPFs programmatically.

     

    https://docs.microsoft.com/en-us/power-automate/developer/business-process-flows-code#retrieve-all-the-rows-instances-for-a-business-process-flow-entity

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • Po5 Profile Picture
    17 on at

    Hi @ChrisPiasecki,

    I can get the active stage id and specific process stage just fine, but I'm not sure how to filter the client data.

     

    For example: I've created a Lead Record below which is currently in the first stage.

    Po5_0-1619587268069.png

    I then perform a request to get the relevant data: (which I actually just used XRM Toolbox to do so it's quicker)
    https://{crm-url}/api/data/v9.2/processstages?$expand=processstage_leadtoopportunitysalesprocess($filter=(_leadid_value eq {lead-guid}))&$filter=(processstage_leadtoopportunitysalesprocess/any(o1:(o1/_leadid_value eq {lead-guid})))&$top=10

     

    From this I'll get the clientdata of the Active Stage which looks like the below: (with guids ommitted)

    {
    "DisplayName": "Existing Contact?",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "parentcontactid",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Existing Account?",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "parentaccountid",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Purchase Timeframe",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "purchasetimeframe",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Estimated Budget",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "budgetamount",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Purchase Process",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "purchaseprocess",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Identify Decision Maker",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "decisionmaker",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Capture Summary",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "description",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Customer Need",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "customerneed",
    "IsRequired": false
    }
    },
    {
    "DisplayName": "Proposed Solution",
    "DisplayLabelId": "guid",
    "Type": "Field",
    "Field": {
    "AttributeName": "proposedsolution",
    "IsRequired": false
    }

    ..... cutoff so it isn't too long.

     

    But from this there's no way to tell whether Customer Need and Proposed Solution are part of the current active stage or not and from the screenshot we clearly know they aren't (they are for sure in the next stage and this continues on for all stages).

     

    Please let me know if I have misunderstood something or this is still unclear.
    I've read through the documentation but it doesn't really give me an answer for this scenario.

     

    Thanks.

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard