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)

Javascript to change Two Options field value

(0) ShareShare
ReportReport
Posted on by 1,328

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

I have the same question (0)
  • Verified answer
    David Jennaway Profile Picture
    14,065 on at

    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);
    }


  • epark06 Profile Picture
    1,328 on at

    Thank you!!

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 April 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