- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 10:05 PM
On the record producer we've mapped to field for LE case table. Then wrote a after insert business rule where im trying to map variable value from LE case table to HR profile table.
(function executeRule(current, previous /*null when async*/) {
var hr= new GlideRecord('sn_hr_core_profile');
hr.addQuery('sys_id',current.subject_person);
hr.query();
while(hr.next()){
hr.location=current.location.toString();
hr.update();
gs.log('test:' + location);
}
})(current, previous);
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2023 10:52 PM
please update as this
1) don't use gs.log() in scoped app as it will break the script
2) also you need to use current.variables to access variable value
(function executeRule(current, previous /*null when async*/) {
var hr= new GlideRecord('sn_hr_core_profile');
hr.addQuery('sys_id',current.subject_person);
hr.query();
if(hr.next()){
hr.location = current.variables.location.toString();
hr.update();
}
})(current, previous);
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-28-2023 10:52 PM
please update as this
1) don't use gs.log() in scoped app as it will break the script
2) also you need to use current.variables to access variable value
(function executeRule(current, previous /*null when async*/) {
var hr= new GlideRecord('sn_hr_core_profile');
hr.addQuery('sys_id',current.subject_person);
hr.query();
if(hr.next()){
hr.location = current.variables.location.toString();
hr.update();
}
})(current, previous);
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