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)

Reset field value to the default optionset option with Javascript

(0) ShareShare
ReportReport
Posted on by

In my quote form, I have a series of fields in a section that I need to clear based on an onChange event elsewhere on the form. For the most part, I have everything all ironed out, but I would like a few of the optionset fields to revert to the default value instead of getting set to null. Is there a way to set those to the default value without having to explicitly declare the default value for each field?

*This post is locked for comments

I have the same question (0)
  • TNS Profile Picture
    1,197 on at

    Hi,

    You can create business rules .. depending on any condition.

    Thanks!

  • Community Member Profile Picture
    on at

    You can't have a business rule trigger onChange though, can you?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    I think you might be able to get that value by using the getInitialValue method

    var defaultValue = Xrm.Page.getAttribute(osName).getInitialValue();

    Xrm.Page.getAttribute(osName).setValue(defaultValue);

    Hope this helps.

  • TNS Profile Picture
    1,197 on at

    Yeah , business rule can be triggered at on change of any field... depending at which scope you are triggering the business rule..

    like if you have two fields a & b ... and you have put a business rule on field 'b ' that if value of a = x then value of b = y ..... and scope of rule is entity ... so on change of a value of b also change...

  • Prashnat Verma Profile Picture
    287 on at

    Hi Aric ,

    Thats not working in crm 2013.

    thanks

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Application Tag says Dynamics CRM Online, not CRM On-Premise 2013.

  • AnujGovil Profile Picture
    10 on at

    Hi Aric Levin Thank you for your fix. It worked for me.

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