Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Catch parent execution context id

(0) ShareShare
ReportReport
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!

  • 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 User Group Leader 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans