Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Javascript to change Two Options field value

Posted on by 1,320

I have this js but it is not changing the value of the two options field. I want it to always change the value from true to false, or false to true. Any help is appreciated.

function test() {
debugger;
value = Xrm.Page.getAttribute("new_convertleadwithoutopportunity").getValue();
alert(value);

if (value = false) {
	Xrm.Page.getAttribute("new_convertleadwithoutopportunity").setValue(true);
}
else {
	Xrm.Page.getAttribute("new_convertleadwithoutopportunity").setValue(false);
}
Xrm.Page.data.refresh(true);}


*This post is locked for comments

  • epark06 Profile Picture
    epark06 1,320 on at
    RE: Javascript to change Two Options field value

    Thank you!!

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Javascript to change Two Options field value

    You need to use == to test for an equality in js. Use:

    if (value == false) {
    	Xrm.Page.getAttribute("new_convertleadwithoutopportunity").setValue(true);
    }
    else {
    	Xrm.Page.getAttribute("new_convertleadwithoutopportunity").setValue(false);
    }


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans