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)

calling a JavaScript function on status change event in opportunity form

(0) ShareShare
ReportReport
Posted on by 1,562

Hello All,

I am calling a JavaScript function on status change event in opportunity form.

Here, I am trying to set a custom option set field value using below code.

  Xrm.Page.getAttribute("CustomOptionSet").setValue(1);

Its not showing with new assigned value,please suggest why its not working.

scenario:
Once,I am Reopen opportunity I need to set option set value.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Instead of Javascript you can use a realtime workflow and put trigger on "Record Status changes" and set your value for optionset.

    community.dynamics.com/.../using-real-time-workflows-to-show-error-messages

  • Tin Profile Picture
    1,562 on at

    Thanks for reply but i want to done this by javascript only

  • ScottDurow Profile Picture
    21 on at

    Javascript events are not designed for running on state change of records because status changes happen using a command bar button -e.g. Win/Lose opportunity. You will have to do it on the server using a realtime workflow as Mohd says.

  • Community Member Profile Picture
    on at

    Please refer below for events that are present at client side:

    msdn.microsoft.com/.../gg334481.aspx

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Tin,

    You can add an on-change event to the state-code field and whenever the status changes, it will fire your event.

    See: http://blog.sonomapartners.com/2016/04/firing-events-in-javascript-when-status-changes-in-dynamics-crm-2013-2015-2016.html

    Hope this helps.

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