web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Order product is not getting updated after being copied from quote product.

(0) ShareShare
ReportReport
Posted on by

Scenario:

I have written a plugin on "Post Operation" of salesorderdetail and the message is "Create". And in this plugin I am trying to update my custom field on salesorderdetail entity to some value.

Note: Both the entities "salesorderdetail" and "quotedetail" are having this custom field and created the mapping of these custom field.

After clicking on "create order" button on quote form, I want the custom field should get updated with my value and plugin should fire but it's not updating the field.

Please let me know if the scenario is not clear.

Any help will be appreciated!

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Radu Chiribelea Profile Picture
    6,667 on at

    Could you please share your code ?

  • Community Member Profile Picture
    on at

    try

               {

                   if (context.InputParameters["Target"] is Entity targetEntity)

                   {

                       if (targetEntity.Contains("somecustomfield"))  

                       {

                           if (context.Depth > 1)

                           {

                               var configurationResponse = SomeExternalAPi(passingvaluefromof "somecustomfield");

                               if (configurationResponse.Success)

                               {

                                   targetEntity.Attributes["customfield"] = configurationResponse.Content.Id.ToString();

                                   service.Update(targetEntity);

                               }

                               else

                               {

                                   targetEntity.Attributes["customfield"] = Guid.Empty.ToString();

                                   service.Update(targetEntity);

                               }

                           }

                       }

                   }

               }

  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at

    From your code there is a condition  if (context.Depth > 1) then do the changes. I wonder if this isn't your issues, as if you are not within a loop the depth should always be 1

    Can you change that condition from  if (context.Depth > 1) to  if (!context.Depth > 1) and see if then your record gets updated?

    If you still see the issue, then I would also implement the tracing service and log messages for debug or use the plugin profiler

    Regards,

    Radu

  • Community Member Profile Picture
    on at

    Hi Radu Chiribelea, I have checked the depth and it's coming as 2 but still I have put my code in (!context.Depth > 1) block as you said, it's by passing.

    Please note that I have registered my plugin at: Pipeline stage - Post Operation, Message - Create, Execution mode - Synchronous.

  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at

    Can you try to enable tracing

    community.dynamics.com/.../implementing-tracing-in-your-crm-plug-ins

    docs.microsoft.com/.../use-itracingservice-plugins

    Or use the plugin profiler community.dynamics.com/.../how-to-debug-plugins-using-profiler

    This might help you narrow down

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Wayne Walton Profile Picture

Wayne Walton 2

#2
Good.Panos Profile Picture

Good.Panos 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans