On selection of variable value system should allow other variable to allow only specific formats
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 05:58 AM
Hi Experts,
Depending on selection of variable value, system should allow only specific set of format to other variable else it should alert.
Let me know if this can be achievable.
Requirement: On selection of Operating system value from the drop down, File system variable should allow specific format (example:
I have used regex expression on change of only one variable "file System". Here is the code.
Thanks, Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 09:50 AM - edited 08-08-2024 09:51 AM
Hi @Jay N
You can try the below Script
On change client script of variable (file system)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var fileSystemVar = g_form.getValue('operating_system');
alert(fileSystemVar) ;
var fileSystemValue = g_form.getValue('file_system');
var windowsPattern = /^[A-Z]:\\(?:[^<>:"/\\|?*\n\r]+\\)*[^<>:"/\\|?*\n\r]*$/;
var linuxPattern = /^\/[A-Za-z0-9_\/]*$/;
if (fileSystemVar == 'windows') {
if (!windowsPattern.test(fileSystemValue) && fileSystemValue !== '') {
alert('Please enter a valid Windows drive path');
g_form.setValue('file_system', ' ');
}
} else if (newValue == 'linux') {
if (!linuxPattern.test(fileSystemValue) && fileSystemValue !== '') {
alert('Please enter a valid Linux/UNIX path, e.g., /usr/local.');
g_form.setValue(''file_system', ' ');
}
}
g_form.setValue('file_system_variable_name', '');
}
Thanks and Regards
Sai Venkatesh