- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 10:44 PM
Hi All/
We are trying to access record producer varibles value using Business Rule. But we are not able to get the values.
Please guide me. Async/Update BR. We submit the Record Producer after that record is creted respective table. We wrote BR of that table.
(function executeRule(current, previous /*null when async*/) {
gs.info('ITP HR service ' + current.hr_service);
var transfer_person = current.variables.employee_name;
gs.log("Abira transfer for " +transfer_person);
var position = current.variables.new_position;
gs.log("Abira Position " +position);
var effecdate = current.variables.effective_date;
gs.log("Abira date " +effecdate);
var country = current.variables.transfered_position_country;
gs.log("Abira country " +country);
var loc = current.variables.transfered_position_location;
gs.log("Abira location " +loc);
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:56 PM
So the BR would run when the record is updated and the HR Service is Matching your service
1) in your BR you cannot use producer object; you need to use current
2) gs.log() won't work in scoped application and your script will break so use gs.info()
(function executeRule(current, previous /*null when async*/) {
gs.info('ITP HR service ' + current.hr_service);
var transfer_person = current.variables.employee_name;
gs.info("Abira transfer for " +transfer_person);
var position = current.variables.new_position;
gs.info("Abira Position " +position);
var effecdate = current.variables.effective_date;
gs.info("Abira date " +effecdate);
var country = current.variables.transfered_position_country;
gs.info("Abira country " +country);
var loc = current.variables.transfered_position_location;
gs.info("Abira location " +loc);
var req_body='{'+
'"effectivedate":"'+effecdate+'",'+
'"trapercountry":"'+country+'",'+
'"location":"'+loc+'",'+
'"Position":"'+position+'",'+
'}';
gs.info('ITP payload details'+req_body);
})(current, previous);
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
‎07-05-2022 10:48 PM
Hi On your form can you see the variable editor? Are Variables are available on the form?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 10:57 PM
Hi Harish,
Variables are the record producer variables. I trying to access those variable using BR for payload.
But my BR is not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:15 PM
Are you sure variables are inserted on incident record? Can you check in question_answer table?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 11:03 PM
Hi,
you should be writing after insert BR on your record producer target table
Are you sure the BR triggers?
Are you sure the variable name is fine?
Script looks good to me
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
‎07-05-2022 11:10 PM
Hi Ankur,
Yes BR is trigger. we got the log 1st for service but variables values not able to pickup using log.
variables name are fine. what should i used either current or producer object ?Please guide me.