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)

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

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