How to set choice values on form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 12:44 AM
Hi All, I have below business requirement
In my catalog form i have two variables
1. Target number - which is reference to target table
2. Complaint - as select box(yes/no)
if we select a target number in first variable as TGT1234(inside that " TGT1234 " form we have a field called "complaint " with data as 'test complaint')
My question is
if i select a target number in first variable and that number form has complaint field data i need to set the second variable complaint as yes and it should be read only.
if i select a target number in first variable and that number form has no complaint field data i need to set the second variable complaint as No and it should be read only.
How can we achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 12:46 AM
Hi,
you can use onChange catalog client script with getReference() callback method
what have you tried so far?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 12:47 AM
Yes ankur i have tried but no luck,
how to identify whether that target number form has complaint data or not?
if possible could you please provide a sample script so that i can try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 01:02 AM
please share your script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 01:39 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.getReference('target_number', doAlert);
function doAlert(number) {
g_form.setValue('u_complaint', number.u_complaint_num);
g_form.setReadOnly('u_complaint',true);
}
//Type appropriate comment here, and begin script below
}