Can I pass a variable from a requested item to the approval?

cmills_1128
Kilo Contributor

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

1 ACCEPTED SOLUTION

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


View solution in original post

10 REPLIES 10

Cynthia,



  can you attach a screen shot of the business rule conditions and script you have right now.




Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


1.JPG



2.JPG


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


that worked!   Thanks!


Hi Cynthia,



Sorry to hear you're having troubles. This is one of those things if I was on your instance as a Technical Consultant I could bang out in about 10 minutes, but going back and forth on the community is a bit more challenging. I recommend reaching out to ServiceNow or one of our partners for a quick professional services engagement (or longer if you have other similar requirements) to see where they can help.