In catalog, we want to set check box as true when condition is true

mounika58
Mega Expert

Below is the code for setting value.

function onChange() {

if (g_form.getValue('variables.UserType') == 'Terminal Server Users')

  {

        g_form.setValue('variables.OutlookEmail',true);

        g_form.setValue('variables.ServiceNowAccount',true);

      g_form.setValue('variables.TerminalAccess',true);

  }

}

When I keep alerts it is showing as true but on the form check box is not getting ticked.

Please help what is missing

1 ACCEPTED SOLUTION

Hi All,



Now it is working after modifying as below.



function onChange() {


//var user = g_form.getValue('variables.UserType');
  if (g_form.getValue('UserType') == 'Terminal Server Users')
  {
        g_form.setValue('OutlookEmail','true');
       
        g_form.setValue('ServiceNowAccount','true');
       
        g_form.setValue('TerminalAccess','true');
     
  }


  else if (g_form.getValue('UserType') == 'External Users with Archroma Laptop')
  {
     


  g_form.setValue('OutlookEmail','true');
  g_form.setValue('ServiceNowAccount','true');
  g_form.setValue('TerminalAccess','false');



  }
     
}


View solution in original post

9 REPLIES 9

Hi Pradeep,



Tried like below but still not working.



function onChange() {


//var user = g_form.getValue('variables.UserType');



  if (g_form.getValue('variables.UserType') == 'Terminal Server Users')
  {
        g_form.setValue('OutlookEmail',true);
        alert(g_form.getValue('variables.OutlookEmail'));
 
  g_form.setValue('ServiceNowAccount',true);
  g_form.setValue('TerminalAccess',true);
  }
  else if (g_form.getValue('variables.UserType') == 'External Users with Archroma Laptop')
  {
      alert('external');


  g_form.setValue('OutlookEmail',true);
  g_form.setValue('ServiceNowAccount',true);
  g_form.setValue('TerminalAccess',false);
  alert(g_form.getValue('variables.TerminalAccess'));
  }

I kept alerts and they are popping up correctly but checkboxes are not getting checked. Please let me know what I am missing.
}


Hi Mounika,



In the if and else if condition still I can see you are using the variables. Can you please remove


g_form.getValue('variables.UserType')


g_form.getValue('variables.UserType')


Remove variables from above i.e g_form.getValue('UserType')


Tried as below but still not working.



function onChange() {


//var user = g_form.getValue('variables.UserType');
  if (g_form.getValue('UserType') == 'Terminal Server Users')
  {
        g_form.setValue('OutlookEmail',true);
        alert(g_form.getValue('variables.OutlookEmail'));
 
        g_form.setValue('ServiceNowAccount',true);
        alert(g_form.getValue('variables.ServiceNowAccount'));
        g_form.setValue('TerminalAccess',true);
        alert(g_form.getValue('variables.TerminalAccess'));
  }


  else if (g_form.getValue('UserType') == 'External Users with Archroma Laptop')
  {
      alert(g_form.getValue('variables.UserType'));


  g_form.setValue('OutlookEmail',true);
  g_form.setValue('ServiceNowAccount',true);
  g_form.setValue('TerminalAccess',false);
  alert(g_form.getValue('variables.TerminalAccess'));
  }
     
}


Hi All,



Now it is working after modifying as below.



function onChange() {


//var user = g_form.getValue('variables.UserType');
  if (g_form.getValue('UserType') == 'Terminal Server Users')
  {
        g_form.setValue('OutlookEmail','true');
       
        g_form.setValue('ServiceNowAccount','true');
       
        g_form.setValue('TerminalAccess','true');
     
  }


  else if (g_form.getValue('UserType') == 'External Users with Archroma Laptop')
  {
     


  g_form.setValue('OutlookEmail','true');
  g_form.setValue('ServiceNowAccount','true');
  g_form.setValue('TerminalAccess','false');



  }
     
}


Perfect


Can you please mark the response if that answers your question.