- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 04:55 AM
Hello ,
I was working on a custom form.
there is a checkbox field on Representative table called validFlag = Boolean
there is Employee table in that we are having Frequent flag (string with drop down values Yes/No)= validFlag(representative table field) + grade (present on Employee table)
Before we use to copy validFlag (true/false)= Frequent flag (Yes/No)
we have before update Business rule
var gr = new GlideRecord('representative');
gr.addQuery('sys_id', current.representative);
gr.query();
if (gr.next()) {
if (gr.validflag == true) {
current.setValue('frequentflag', 'yes');//Now Frequent flag = validFlag + Grade
} else {
current.setValue('frequentflag', 'no');
}
}
How to append validFlag and Grade and set to Frequent flag?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 05:17 AM
Try to concatenate the validFlag (converted to "Yes"/"No") with the Grade field value, please try with below script:
var gr = new GlideRecord('representative');
gr.addQuery('sys_id', current.representative);
gr.query();
if (gr.next()) {
var validFlagValue = gr.validflag ? 'Yes' : 'No'; // Convert boolean to Yes/No
var gradeValue = current.grade || ''; // Ensure grade is not null
var frequentFlagValue = validFlagValue + ' ' + gradeValue; // Append values
current.setValue('frequentflag', frequentFlagValue.trim()); // Remove any trailing spaces
}
Please mark correct/helpful if this helps you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 06:20 AM
but how Frequent flag will show Yes 10 if the choice is only Yes?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-20-2025 07:16 AM
that what i am not understanding how i should add this value
validFlag = true and Grade = 10
Frequent flag = Yes (validFlag) + 10(how to convert true to Yes)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:21 AM
please discuss with your customer about this requirement.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader