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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans