- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 11:52 AM
Could I achieve this with a client script? I created a string field on the approval form, but I need to figure out how to pass the text from the request to the approval form.
The variable on the item is a single line text variable named bms_program_name
The field on the approval is a string field named u_bms_program_name
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 03:14 PM
Cynthia,
I have skimmed through your comments and noticed that you have only checked insert check-box on the business rule. You will have to check the update check-box too and add this script. It should work now
(function executeRule(current, previous /*null when async*/) {
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.query();
while (app.next()) {
app.u_bms_program_name = current.variables.bms_program_name;
app.update();
}
})(current, previous);
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 12:28 PM
Hi Cynthia,
I would do this with an after business rule on the sc_req_item (requested item) table.
After the request item moves to approval state (or whatever state you use to wait for approval, or perhaps the approval field is set to requested), it triggers the business rule to lookup any related approvals and update the field with the value from the variable. The key is something like:
var app = new GlideRecord('sysapproval_approver');
app.addQuery('approval_for', current.sys_id);
app.query();
while (app.next()) {
app.u_bms_program_name = current.variables.bms_program_name;
app.update();
}
You'll want to ensure that your business rule condition filters on the proper request items as I don't suspect that variable is going to be on all of them so it can skip the ones that don't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 02:53 PM
Hi Chuck,
I created the after business rule and added the filter conditions to look for the specific items and the stage is "Legal Approval", which is the stage and approval I'm looking to add the client name to. It's not filling in the client program name as expected.
I checked the box next to insert.
Java script isn't my strong suit. There was some pre-populated script in the advanced script field. Here's the script:
(function executeRule(current, previous /*null when async*/) {
var app = new GlideRecord('sysapproval_approver');
app.addQuery('approval_for', current.sys_id);
app.query();
while (app.next()) {
app.u_bms_program_name = current.variables.bms_program_name;
app.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 02:58 PM
Cynthia,
It should be sysapproval in the addQuery() as shown below.
Change this line"app.addQuery('approval_for', current.sys_id);" to "app.addQuery('sysapproval', current.sys_id);"
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2016 03:04 PM
Hi Adhinay,
I updated the script and see no change in the approval record.
Best,
Cynthia