Excluding Item based on List Collector Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 06:59 AM - edited ‎07-07-2023 07:00 AM
I have been given a requirement to exclude "Modify" from the select box item in a Variable Set. when "RFD" is selected on the Request the RFD value is coming from list collector in the "Custom Action Table" we have built. I'm trying to build a Client script to do this. I have a similar script that excludes but that is just for a Yes/No variable. but it's looking at a variable not a external table. Based on research and trying started down this path but i can't get it to work.. can someone help me to understand what i'm not seeing
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var list = g_form.getValue('application_project'); //getting value of list collector
if(list.indexOf('RFD') > -1 ){ //item in list collector
g_form.removeOption('logging_account', 'Modify'); //action to proform when list selected
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 07:07 AM
The script you provided seems to be on the right track. However, there are a few points to consider:
Make sure the variable set containing the select box variable is loaded before the script executes. If the variable set is loaded asynchronously, you might need to wrap the script in the g_form.$document.ready() function to ensure it runs after the form elements are available.
Confirm that the value of the list collector variable is correctly retrieved. You can add a console.log(list) statement to check if the value is as expected. Open the browser's developer console to view the logged output.
Verify that the option label you want to exclude from the select box is indeed "Modify". Double-check the spelling and case sensitivity.
Here's an updated version of your script, taking these considerations into account:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
g_form.$document.ready(function () {
var list = g_form.getValue('application_project');
if (list.indexOf('RFD') > -1) {
g_form.removeOption('logging_account', 'Modify');
}
});
}
By using the g_form.$document.ready() function, the script will wait for the form to be fully loaded before executing, ensuring that the form elements are accessible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 08:22 AM
Hi @Walter Toney,
Try this updated scripts:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var list = g_form.getValue('application_project'); //getting value of list collector
if (list.toString().indexOf('RFD') > -1) { //item in list collector
g_form.removeOption('logging_account', 'Modify'); //action to proform when list selected
}
}
Also, make sure that Modify is correct value for that select box options.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 12:30 PM
Sorry I have not been able to look at this until now. I will work with it and let you know the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2023 04:45 AM - edited ‎07-12-2023 04:49 AM
This did not Work. I believe it is because of my description... it's a MRVS not just a variable set
so... the user will select item from the List collector and based on that selection I want to have Modify off of the select box on a MRVS