Skip to main content

Notifications

Microsoft Dynamics CRM forum
Suggested answer

Catch parent execution context id

Posted on by 92

Hello,

I hope someone will help me with my quest.

I created a plugin for quotes in CRM to retrieve the parent guide when the quote is revised. when I retrieve the parent execution context, I get the new quote id that was created.

I registered this plugin on the pre-operation create of the quote table.

In the screenshot below I used context.ParentContext to get the parent of the record created, but the parent guide is returning the new GUID created and not the parent one.

pastedimage1674209471606v1.png

I tried to use the context.ParentContext.ParentContext (grandparent method) but the GUID is returning all 0s.

Can someone assist me to get the GUID of the revised quote?

Thank you in advance!

Categories:
  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Catch parent execution context id

    Right.

  • MBaba Profile Picture
    MBaba 92 on at
    RE: Catch parent execution context id

    Hello Pradeep Rai ,

    \In the case you shared, you are assuming that the last product is always being revised. In that way, it will work, but I mean if the revised quote is not the last one. Getting quote no. and decrementing the revision by one is not the solution, in this case, that's why I want to get the GUID of the revised quote.

    Thank you

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Catch parent execution context id

    Hi,

    let's consider below example.

    pastedimage1674221016304v2.png

    Suppose, You are Revising the Quote B
    Then logic will on Create of Quote

    1. Get Quote Number of Quote
    2. Get Quote Revision Number
    3. Now substract the Revision with 1
    4. Now you can search for Quote Record where Quote Number eq "<value found in step 1>" and Revision Number eq "Value found in step 3".

    This you will have previous record.

    Other way is you can retrieve latest record from "Quote Close" entity based created on.



    pastedimage1674220987436v1.png

  • MBaba Profile Picture
    MBaba 92 on at
    RE: Catch parent execution context id

    Hello Naveen Ganeshe ,

    I want to get the revised quote not closed.

    For example, I have 4 closed quotes (1,2,3,4) but I want to revise the 2nd quote and get its child records to the new quote.

    The problem is I'm not able to get the GUID from the Parent context and I cannot filter on last number revised neither on last modified.

    The best practice is to catch the GUID of the parent record, but this approach is not working.

    Thank you

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Catch parent execution context id

    I agreed with Naveen.

  • Suggested answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 Moderator on at
    RE: Catch parent execution context id

    Hi,

    Looks like you have quote no. in the plugin for the previous quote. You can search the quote by quote no. where the status is closed. This way you can get the quoteId.

  • MBaba Profile Picture
    MBaba 92 on at
    RE: Catch parent execution context id

    Hello Pradeep Rai ,

    Thank you for the fast reply. I tried to use context.ParentContext.ParentContext.InputParameters.InputParameters("QuoteId") but it is throwing a syntax error in visual studio

  • Suggested answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 on at
    RE: Catch parent execution context id

    Hi,

    I would suggest you can retrieve the quote record using the QUOTEID and Status as Closed.

    because when we revise the quote then New Quote Created and Old Quote Status Changes to Revised.

    Also, try below code:

    context.ParentContext.ParentContext.InputParameters.InputParameters("QuoteId")

    Found in below discussion:

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,469 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans