Script to populate a field based on another fields selection

jmbrake
Kilo Expert

Can anyone assist with a script to fill a Yes/No field based on another fields selection.

Background Information:

This is an Order Guide item.   I am creating a catalog client script called:   Set Agreement Value Based on Dept

The Order form requires fields to be filled in, like name and department.   Initially the form comes up with no entries.

When I select 'Info Technology' from the reference field from the Department table , I want the field on the Order Guide Form for Confidentiality Agreement to automatically change from No to Yes.

Here is what I have tried, unsuccessfully.

Function onChange() {

  var dept = g_form.getValue('department');

  if(dept == 'info technology'){

  g_form.setValue('agreement','Yes');

  }

}

Form screen shots below:   First is the Department selection fields; second is the Yes/No question I want auto populated based on the department chosen.

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }



var dept = g_form.getReference('department').name;


if(dept == 'info technology'){


      g_form.setValue('agreement','Yes');


  }


}




Try above script.



Regards,


Hardik Vora


View solution in original post

8 REPLIES 8

function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }



var dept = g_form.getReference('department').name;


if(dept == 'info technology'){


      g_form.setValue('agreement','Yes');


  }


}




Try above script.



Regards,


Hardik Vora


The script no longer errors out, but it also does not change the 'agreement' field to Yes.   Sorry, this is very frustrating for someone who does not know scripting.


I had to capitalize the I and T in Info Technology and then it worked.   Thank you very much


ewereer
Giga Contributor

Hi ,


I have a issue. I need to populate a reference field based on the location of the logged-in user.



ex- if the logged-in user is from X country ,the fulfillment group should populate Y.


          and if logged-in user is from A country, the fulfillment group should populate B.




Thanks.