Set default choice through catalog client script

Kim Jenson
Kilo Contributor

Hello experts,

I'm new to coding, and trying to accomplish a task, not sure how this can be done.

I have this If/else statement that i'm checking to see set choice list for the variable, which works as intended. However, I want to set choices depending on which is true. If 'answer = 2 then default type to 'Add User' else default 'type' to 'Request info'. Can this be possible within this If/else condition?

  if (answer == 2) {

  g_form.addOption('type', 'Add User', 'Add User');

  g_form.addOption('type', 'Edit User', 'Edit User');

  } else {

  g_form.addOption('type', 'Request Info', 'Request Info');

  g_form.addOption('type', 'Request Access', 'Request Access');

  }

1 ACCEPTED SOLUTION

Thanks for the details Kim. Here is the updated code.



  if (answer == 2) {


  g_form.addOption('type', 'Add User', 'Add User');


  g_form.addOption('type', 'Edit User', 'Edit User');


g_form.setValue('type', 'Add User');


  } else {


  g_form.addOption('type', 'Request Info', 'Request Info');


  g_form.addOption('type', 'Request Access', 'Request Access');


g_form.setValue('type', 'Request Info');


  }


View solution in original post

7 REPLIES 7

UI policy should also work as expected. Can you assign highest order number to the UI policy and check once.


It works as expected. For some reason the UI Policy condition was removed, so I added it back.



Thank you so much for your help!


Awesome. Thanks Kim for participating in the community!