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)

How do you write an if statement to equal an optionset value?

(0) ShareShare
ReportReport
Posted on by

I am trying to write an if statement, that will check to see if remittancefile is selected as No in the option field.  If so then I want it to set the values of the following fields.  I am pretty sure I have the set values correct.  I just cannot get the if statement working properly.  I am not sure if it is actually the if statement or the get attribute I am using.  Any help is greatly appriciated.

Code:

function NAIfNo( )

{

var Name = Xrm.Page.data.entity.attributes.get("new_deadlinetime");

//get the value of remittance file

var file = Xrm.Page.data.entity.attributes.get("new_remittancefile");

 

//check to see if remittance file equals “no”

//the optionset value data for no is 100000001

if (file == No)

                                {

                //set values to following fields if remittance file is “no”

                Xrm.Page.getAttribute("new_remittanceformat").setValue(999999999);

                Xrm.Page.getAttribute("new_dpremittance").setValue(999999999);

                Xrm.Page.getAttribute("new_deliveryremittance").setValue(999999999);

                Xrm.Page.getAttribute("new_remittancepassword").setValue(999999999);

                Xrm.Page.getAttribute("new_frequencyremittance").setValue(999999999);

                Name.setValue("N/A");

                Xrm.Page.getAttribute("new_paperstatement").setValue(999999999);

 

                                }

}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    I finally found what I was looking for, I hope this will help someone in the future.

    function NAIfNo( )
    {
    var Name = Xrm.Page.data.entity.attributes.get("new_deadlinetime");
    //my issue was here, I needed to get the optionset and display it as text
    var file = Xrm.Page.getAttribute("new_remittancefile").getSelectedOption().text

    if (file == "No")
      {

     Xrm.Page.getAttribute("new_remittanceformat").setValue(999999999);
     Xrm.Page.getAttribute("new_dpremittance").setValue(999999999);
     Xrm.Page.getAttribute("new_deliveryremittance").setValue(999999999);
     Xrm.Page.getAttribute("new_remittancepassword").setValue(999999999);
     Xrm.Page.getAttribute("new_frequencyremittance").setValue(999999999);
     Name.setValue("N/A");
     Xrm.Page.getAttribute("new_paperstatement").setValue(999999999);
     
      }

    }

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans