- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 11:46 AM
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');
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 12:14 PM
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');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 12:24 PM
UI policy should also work as expected. Can you assign highest order number to the UI policy and check once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 12:35 PM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 04:57 PM
Awesome. Thanks Kim for participating in the community!