Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone, I create record A. I have a plugin for create post-operation of my record A. On this step (create post operation), I create records of another entity type and want to set a lookup field that references record A. I get an error telling me the entity I want to reference doesn't exist. Is there a way I can achieve this? It seems my entity is not created yet... Thanks a lot

*This post is locked for comments

  • Inogic Profile Picture
    Inogic 438 on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Hi Frantz,

    You can create synchronous workflow which will triggered on create of "Entity A".

    In this workflow, add a step to create the "Entity B" record and then click on set properties button.

    Set the "Entity A" lookup field value as "Entity A" using "Form Assistant" which is present at right side .​


    Hope this will help you.

    Thanks!
    Sam​

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Can you check if you have any other synchronous plugin steps registered on same entity for post operation? If so, make execution order of your step to the last and check if it solves your problem.

    On post operation, the record is already created and you should not face this problem. I have tried similar operation successfully.

  • Suggested answer
    ansrikanth Profile Picture
    ansrikanth 3,115 on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Hi

    I just tested it in my env and able to reproduce it.. It sounds pretty weird to me, the only logical reason "could" be, the record is created but still not committed in to the database and so it is not able to find the record. Until post operation also successfully completes, the record won't be committed. But what makes me wondering is, when the record id (guid) is created, what troubles them to create related record and commit both at once ? Not sure, I think I need to review the plugin concepts once again.

    Anyways, the quick possible alternate for you could be, using a real time workflow. I just tested it with a real time workflow and found that is working fine. (Hoping you are working on crm2015+  and there isn't much complex logic in creating child records).


    All the best !!

    Srikanth

  • Suggested answer
    Nuno Profile Picture
    Nuno 2,005 on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Hi,

    On post-create the entity A is already created. This issue should not happen.

    The id of the entity A just created, is available on OutputParameters.

    Guid entityAId = (Guid)context.OutputParameters["id"];

    From here you can set the entityreference

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Your point is clear. What version of CRM do you use? Can you please provide your plugin's code?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    The thing is that I have a grid on form of entity A that shows entity b's that have a lookup to record of entity a. The users have to refresh to get the grid populated. Is there another way The user could land of form after creation and have the grod already populated? Is my point of concern clear?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Error in post-operation plugin, trying to create new recors that have a lookup to newly created record

    Hello Frantz,

    Try to switch plugin to Async execution mode. That should resolve your issue.

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,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans