- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 03:31 AM
Hi,
I have two checkboxes Server and SPM Test Names if these checkboxes are true then I need to populate those names in a new field.
I have written individual Onchange client scripts so either the Server or SPM Test Name is getting placed into the variable but I want to have both names(Server,SPM Test Names) to be placed if both checkboxes are selected.
Please find below my code:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'true') {
g_form.setValue('request_type', 'Server Names');
}
else
g_form.setValue('request_type', ' ');
}
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue == 'true'){
g_form.setValue('request_type', 'SPM Test Name');
}
else
g_form.setValue('request_type', ' ');
}
Please help. Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:18 AM
If the Catalog Item variable names are 'server' and 'spm_test_names', something like this should work for server onChange:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'true') {
if (g_form.getValue('spm_test_names') == 'true') {
g_form.setValue('request_type', 'Server Names SPM Test Name');
} else {
g_form.setValue('request_type', 'Server Names');
}
} else if (g_form.getValue('spm_test_names') == 'true') {
g_form.setValue('request_type', 'SPM Test Name');
} else {
g_form.setValue('request_type', ' ');
}
}
If 'Server Names' and 'SPM Test Name' are not literal values you can use a + to concatenate within the setValue...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 03:47 AM
Hi @Shidhi
You can create a Business rule for this requirement instead of a Client Script and follow the below steps:
1. Create a Business Rule
2. Add conditions in the business rule like (Server is True and SPM Test Names is True).
3. In the 'Actions' tab use the Set field values option to set particular values on the field.
4. Otherwise, you can use the 'Advance' tab to set the particular value on the field.
Please mark my solution as Helpful and Accepted, if it works for you in any way!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:04 AM
This was a catalog item, and those checkboxes are catalog item variables. Could you please suggest an approach here.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:26 AM
@Shidhi, Is the request type field on the catalog item or somewhere else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:57 AM
@Shidhi Can you please confirm?