Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

(0) ShareShare
ReportReport
Posted on by 2

Hi

We have a business process flow that goes from lead to opportunity to project (a custom entity). The process works perfectly, but now that we're trying to import data into different stages of the process, we see there is a problem introduced by the fact that the import doesn't generate the BusinessProcessFlowInstance record, and so you cannot move either forward or backward off the current entity, e.g. if you import at a stage that references the opportunity record, you can't move forward to the project entity stages, or backward to the lead stages.

Does anyone know a SUPPORTED way of generating these records? The obvious unsupported way is to generate them in SQL directly...

Thanks
James

*This post is locked for comments

  • Hussman Profile Picture
    Hussman 3,755 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    You say here that it is supported, yet in your article you say it is NOT supported. You do realise that people that don't know how CRM works will implement what you described in your blog post? Very irresponsible. 

  • Suggested answer
    MagnetismXRM Profile Picture
    MagnetismXRM 6,230 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Hi, a little late with the answer but for anyone else wanting to do this in a supported way, here you go www.magnetismsolutions.com/.../programmatically-move-cross-entity-business-process-flow-stages-in-crm-2016

  • Suggested answer
    James Profile Picture
    James 2 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Thanks Scott - that's what we feared. For anyone's reference, the unsupported mechanism that seems to work is to run the below SQL statement (we only used 3 entities, namely lead, opportunity and new_customentity):

    INSERT INTO BusinessProcessFlowInstance

    (BusinessProcessFlowInstanceId,Entity1Id,Entity1ObjectTypeCode,Entity2Id,Entity2ObjectTypeCode,Entity3Id,Entity3ObjectTypeCode,ProcessId,ProcessStageId)

    SELECT NEWID() AS BusinessProcessFlowInstanceId

    , L.leadid AS Entity1Id

    , 4 AS Entity1ObjectTypeCode

    , O.opportunityid AS Entity2Id

    , 3 AS Entity2ObjectTypeCode

    , P.new_customentitid AS Entity3Id

    , <ObjectTypeCodeOfCustomEntity> AS Entity3ObjectTypeCode

    , COALESCE(P.processid, O.processid, L.processid) As ProcessId

    , COALESCE(P.stageid, O.stageid, L.stageid) AS ProcessStageId

    FROM FilteredLead AS L

    LEFT JOIN FilteredOpportunity AS O

    ON L.qualifyingopportunityid = O.opportunityid

    LEFT JOIN Filterednew_customentity AS P

    ON O.new_customentityid = P.new_customentityid --This link existed in our customisations, you will have to find your own way to link your Opportunity to your new_customentity

    LEFT JOIN BusinessProcessFlowInstance PF

    ON Entity1Id = L.leadid

    WHERE PF.BusinessProcessFlowInstanceId IS NULL

    AND COALESCE(P.processid, O.processid, L.processid) IS NOT NULL

    Hope this helps someone!

    Thanks

    James

  • Suggested answer
    ScottDurow Profile Picture
    ScottDurow 19 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Unfortunately at this time you can't reliably set up multiple entity BPFs on import due to the BusinessProcessFlowInstance not being available to the SDK.

  • PhuocLV Profile Picture
    PhuocLV 347 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Please check my comment in this post:

    community.dynamics.com/.../139884.aspx

  • James Profile Picture
    James 2 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Hi Aileen - unfortunately, while that imports into the correct stage (we'd managed to get that part right), it doesn't generate the internal BusinessProcessFlowInstance record in the CRM database. Consequently, you cannot move across entity types in your imported records.

    Thanks

    James

  • Aileen Gusni Profile Picture
    Aileen Gusni 44,524 on at
    RE: How to import to a particular stage in a Business Process Flow with multiple entity types along the flow

    Hi CRM_Minion,

    Is this link helping you?

    community.dynamics.com/.../139884.aspx

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans