client script doesn't work with passing sys ids

service buzz
Tera Contributor

Hi Team,

 

I have  written a client script on change to make the field invisible for some of the companies .

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   alert('enter change');
    if(company == 'fa652899db674410e2604f7405961985' ||'62652899db674410e2604f740596193c'||'02b56cc91beaf098bbc299b59b4bcb98'||'6a65e499db674410e2604f74059619ef'||'d48428c8db730594dd7efad3f3961917'||'58472644dbd1f414e57455fbd39619d4')
{
if(det_con == 'yes')

    {
        alert('enter if');
        g_form.setMandatory('loc_it',false);

     g_form.setDisplay('loc_it',false);
     
    }

}
   
   

   //Type appropriate comment here, and begin script below
   
}
 
this is not working any thing wrong with syntax because it always high light the if line where company sys ids are provided
8 REPLIES 8

Community Alums
Not applicable

Hi @service buzz ,

I checked your given script and I didn't found the variable 

if(det_con == 'yes') here I didn'nt found declearation of det_con this variable 

 

May be you can check after removing it 

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   var det = g_form.getValue('det_con');
   alert('enter change');
    if(company == 'fa652899db674410e2604f7405961985' ||company=='62652899db674410e2604f740596193c'||company=='02b56cc91beaf098bbc299b59b4bcb98'||company=='6a65e499db674410e2604f74059619ef'||company=='d48428c8db730594dd7efad3f3961917'||company=='58472644dbd1f414e57455fbd39619d4')
{
if(det == 'yes')

    {
        alert('enter if');
        g_form.setMandatory('desk_location',false);

     g_form.setDisplay('desk_location',false);
     
    }

}
   
   

   //Type appropriate comment here, and begin script below
   
}

Community Alums
Not applicable

Hi @service buzz ,

Can you please tell me what's the data type is det or you can do small change like 

var det = g_form.getValue('det_con');
   alert('enter change = ' + det);
 
And than you can add that value in if condition it will work than.
Please mark my answer correct and helpful if this works for you
 
Thanks and Regards 
Sarthak

Lauri Arra
Tera Guru

The variable 'company' is not defined. Should this come from the active user's record, or is it a field on the form?