- 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 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 05:31 AM
try this. I assume your business rule runs Before
var grRep = new GlideRecord('representative');
grRep.addQuery('sys_id', current.representative);
grRep.query();
if (grRep.next()) {
var validFlag = grRep.validflag;
var grade = current.grade; // Assuming 'grade' is a field on the Employee table
var frequentFlagValue = (validFlag ? 'yes' : 'no') + ' ' + grade;
current.setValue('frequentflag', frequentFlagValue);
}
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 05:35 AM
your frequent flag field is true/false
your grade field is of what type?
what's your exact business 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 05:57 AM
Thank you for response @Ankur Bawiskar
validFlag = Boolen (True/False)
Frequentflag = String (drop down Yes/No)
Grade = Integer
here my requirement is
Frequent Flag should represent validFlag (true/false to Yes/No)+ Grade.
lets say validFlag = true Grade = 10
it should show in Frequent flag = Yes 10
show Frequent flag with both field values