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)

WebApi change quote status, multiple status changes

(0) ShareShare
ReportReport
Posted on by 5,241

I had an issue with a workflow running three times. I've check the audit history and I did see that the status was changed three times when I made a REST call to change te status (from draft -> draft -> active -> active). 

I send a PATCH request to the rest endpoint to change the status and I was setting the statecode=1 and statuscode=2. This resulted in setting the quote active twice. 

Now I've changed it to only statecode=1.  And there's only one record in the log of setting the quote active. However, just before the quote is set active, it's first updated to Draft, a status it already had. Because CRM detects both status changes, the workflow is triggered twice. In my workflow I do check if the status is active, but because it's after the event (for a synchronous workflow) or an async workflow, it will check the status of the quote en for both workflows it's active.

I've checked when I make the REST call outside of CRM, and I see that the status is changed twice (draft -> draft, and draft -> active). So the underlying cause is the REST call.

When I check how to change the status with JavaScript, most references I get use SOAP with SetStateRequest, however I don't want to use SOAP. And the SetStateRequest is not available for the webapi.

Any ideas on how to solve this? For the user experience I would really like to change status with JS.

*This post is locked for comments

I have the same question (0)
  • Tim Dutcher Profile Picture
    2,100 on at

    Web API supports CloseQuoteRequest, ReviseQuoteRequest, etc.

    I haven't tried it, but my guess is that using those won't lead to multiple pipeline messages.

  • JohnAnonymous Profile Picture
    5,241 on at

    Tim,

    If I look into the documentation at the C# example I see that it's done with the SetStateRequest:

      // Activate the quote
                        SetStateRequest activateQuote = new SetStateRequest()
                        {
                            EntityMoniker = closeQuote.ToEntityReference(),
                            State = new OptionSetValue((int)QuoteState.Active),
                            Status = new OptionSetValue((int)quote_statuscode.InProgress)
                        };
                        _serviceProxy.Execute(activateQuote);


    I'm having a lot of trouble finding out how to do this with the WebApi. I'm specifically looking at an option to set the quote active.

  • Tim Dutcher Profile Picture
    2,100 on at

    This thread appears to be related to the issue you're running into:

    community.dynamics.com/.../210285

    I'm just starting a project where I'll be dealing primarily with the Quote entity and programmatically setting the status. I'll report back if I run into similar issues and with any ways around the multiple messages.

  • JohnAnonymous Profile Picture
    5,241 on at

    Thanks for the thread reference. I didn't find this documentation before:

    msdn.microsoft.com/.../dn932124.aspx

    It does state that if you update fields and the status, there will be two events. But in my case I only update the status. People from the other thread had the same issue.

  • Community Member Profile Picture
    on at

    Any update on this? I also am looking for a way to update the status of a quote using the web api so that I can then close the quote as lost. Thanks! I'll report back if I figure it out.

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
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans