Skip to main content

Notifications

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,558

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

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: calling a JavaScript function on status change event in opportunity form

    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.

  • Community Member Profile Picture
    on at
    RE: calling a JavaScript function on status change event in opportunity form

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

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

  • ScottDurow Profile Picture
    19 on at
    RE: calling a JavaScript function on status change event in opportunity form

    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.

  • Tin Profile Picture
    1,558 on at
    RE: calling a JavaScript function on status change event in opportunity form

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

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: calling a JavaScript function on status change event in opportunity form

    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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans