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

Announcements

No record found.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans