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)

Update custom field based on status change for Quote

(0) ShareShare
ReportReport
Posted on by 45

I need to update "activateQuote " field to Yes(True) if the Quote is "Active" or "Won". Can anyone tell me whats wrong with this ?

var activateQuote = Xrm.Page.getAttribute("new_activatequote").getValue();

var quoteStatus = Xrm.Page.getAttribute("statecode").getText();
if ((quoteStatus == "Won") || (quoteStatus == "Active")) {
Xrm.Page.getAttribute(activateQuote).setValue(true);
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    You issue is with the setValue line:

    Should be:

    Xrm.Page.getAttribute("new_activatequote").setValue(true);

    You can also do:

    var activateQuote = Xrm.Page.getAttribute("new_activatequote");

    var quoteStatus = Xrm.Page.getAttribute("statecode").getText();

    if ((quoteStatus == "Won") || (quoteStatus == "Active"))

    {

      activateQuote.setValue(true);

    }

    Hope this helps.

  • Sai Ankith MCP Profile Picture
    45 on at

    Ahhhh.... I tried that but still does not work. Is it because once the Quote is turned "Active" or "Won" all the fields are read-only?

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    if the quote is won or closed or active, the field will become read only, perhaps you can go for workflow / plugin in this case. Please consider the trigger point and the proper checking conditions, because it might fall into infinite loops if does not handle well enough.

    https://edwardsdna.com/2009/09/01/updating-a-crm-record-when-the-record-is-in-a-read-only-state-such-as-closed-or-completed/

  • Sai Ankith MCP Profile Picture
    45 on at

    Awesome ! The workflow worked(Used Real-time).. You are Awesome Fun Wei Hie..

  • Sai Ankith MCP Profile Picture
    45 on at

    Thanks for reviewing my code Aric.

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