locked
how to set the two option set value set to yes/no using if statement RRS feed

  • Question

  • Hi All,

    I need  to set the two option set value set  to yes/no using if statement

    Below is my javascript  but its not working where 'new_gvadelta' is a money value with 2 decimal places

    Any help much apprecited

    Thanks

    function CalculateBusinessImproved() 
    {
    
    
     var value1 = (Xrm.Page.getAttribute('new_gvadelta').getValue()!=null ?
     parseFloat(Xrm.Page.getAttribute('new_gvadelta').getValue()):null); 
    
    
    if (value1>0)
     {
     
    
    Xrm.Page.getAttribute('new_businessimproved').setValue('1'); 
    
     
     }
     else{
      (value1 <= 0) 
     
    	Xrm.Page.getAttribute('new_businessimproved').setValue('0'); 	
     }
    }
    


    Pradnya07

    Thursday, May 15, 2014 12:02 PM

All replies

  • if the field is a two options you need to use true/false, like:

    function CalculateBusinessImproved() 
    {
     var value1 = (Xrm.Page.getAttribute('new_gvadelta').getValue()!=null ?
     parseFloat(Xrm.Page.getAttribute('new_gvadelta').getValue()):null); 
    
    if (value1>0)
     {
    Xrm.Page.getAttribute('new_businessimproved').setValue(true); 
     } else {
    Xrm.Page.getAttribute('new_businessimproved').setValue(false); 	
     }
    }


    My blog: www.crmanswers.net - Rockstar 365 Profile


    Thursday, May 15, 2014 12:45 PM
  • i get the below error


    Pradnya07

    Thursday, May 15, 2014 1:26 PM
  • the error belongs to the function name, not of the calculation code, probably you didn't attache the onchange event to the right library or your library contains extra brackets somewhere in the code.

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Thursday, May 15, 2014 1:35 PM