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 01:43 AM
variable u_complaint is of what type?
you want to store this with true/false or yes/no?
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 02:10 AM
u_complaint is choice type variable as choices are YES,NO,NA
I want to set YES if complaint field has data over the selected record
else have to set NO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 02:25 AM
Hi,
then update as this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var number = g_form.getReference('target_number', doAlert);
function doAlert(number) {
if(number.u_complaint_num){
g_form.setValue('u_complaint', 'yes');
g_form.setReadOnly('u_complaint',true);
}
else{
g_form.setValue('u_complaint', 'no');
}
//Type appropriate comment here, and begin script below
}
}
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 11:24 AM
tried with your script and its not working ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 08:22 PM
Hi,
what debugging you performed?
did you check what value came in the callback method
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader