web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

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

  • Aileen Gusni Profile Picture
    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.

  • James Profile Picture
    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

  • PhuocLV Profile Picture
    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

  • Suggested answer
    ScottDurow Profile Picture
    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.

  • Suggested answer
    James Profile Picture
    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
    MagnetismXRM Profile Picture
    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

  • Hussman Profile Picture
    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. 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans