- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 10:37 PM
I would like to write a on submit catalog scripts but im not sure how to write it based on below scenario.
I have created 5 list collector variables as per below.
1. Variable A
2. Variable B
3. Variable C
4. Variable D
5. Variable E
Scenario A
If any 1 of the variables below is populated the requester can add to cart or order now in service catalog
1. Variable A (empty)
2. Variable B (empty)
3. Variable C (populated)
4. Variable D (empty)
5. Variable E (empty)
Scenario B
If all variables below are empty the requester can't add to cart or order now in service catalog and an alert message should prompt out that requester must populate 1 of the variables.
1. Variable A (empty)
2. Variable B (empty)
3. Variable C (empty)
4. Variable D (empty)
5. Variable E (empty)
Thank you
Regards,
TMKam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 11:32 AM - edited 06-05-2023 11:34 AM
Hi, it meant to be used like this. It looks like the function is missing the closure parathesis " } ".
function onSubmit() {
var a = g_form.getValue('var1');
var b = g_form.getValue('var2);
if(a || b) {
return true;
} else {
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 12:07 AM
Hi,
You need to use the g_form.getValue() method to get the values of all the variables. Once you get the values put a if condition where you use OR condition to check atleast one variable has the value and then accordingly you can return true or false.
var a = g_form.getValue('var1');
var b = g_form.getValue('var2);
if(a || b){
return true;}
else {return false;}
Try this and let me know if this is helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 12:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 11:32 AM - edited 06-05-2023 11:34 AM
Hi, it meant to be used like this. It looks like the function is missing the closure parathesis " } ".
function onSubmit() {
var a = g_form.getValue('var1');
var b = g_form.getValue('var2);
if(a || b) {
return true;
} else {
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2023 07:27 PM
Dear SG23,
Thank you for the solution and I have enhanced it as per below.