- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 10:47 PM
Hi All,
I have a requirement for a catalogue item to make atleast one variable( out of three different variable type fields) to be set as mandatory initially and when one of those three variables are answered, then the other two need not be mandatory. Please help me how to achieve this( UI Policy / catalog client script). Thank you.
The above three variables are displayed when " Yes" is selected for a Yes./No Variable.
Three variables are:
1. Variable Question: Sample text field
Name: sample_text
2.Variable Question: Sample Reference Field
Name: rf_field
3. Vaiable Question: Sample Multi Line Text
Name: mutliline_text
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2020 12:20 AM
Try onSubmit client script
var a = g_form.getValue("sample_text");
var b = g_form.getValue("rf_field");
var a = g_form.getValue("mutliline_text");
if(a == "" && b == "" && c == "") {
alert("Kindly fill any one of these field");
return false; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2020 03:59 AM
Hi Mr,
Sorry for delay in response!
Thank you for providing onSubmit Client script for my requirement. It worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2020 01:04 AM
Client Script
function onSubmit() {
var mandatoryVars = 'sample_text,rf_field,mutliline_text';
var passed = forceMandatoryCheckboxes(mandatoryVars);
if (!passed) {
var message = 'You must enter at least one variable field.';
g_form.addErrorMessage(message);
return false;
}
}
function forceMandatoryCheckboxes(mandatory) {
mandatory = mandatory.split(',');
var answer = false;
for (var x = 0; x < mandatory.length; x++) {
if (g_form.hasField(mandatory[x])) {
if (g_form.getValue(mandatory[x]) != '') {
return true;
}
}
}
return false;
}
UI Policy: