Justin Loftas
Tera Guru

Hi Nick,

You are passing current into your insertapprovalrecord function but then not using it. While current would be available to your script include functions directly it's good practice to pass them as arguments.

insertapprovalrecord: function(request){
if (gs.nil(request)){
  return;
} 

var gr = new GlideRecord('x_intp_custom_appr_custom_approval');
gr.initialize();
gr.approver = request.requested_for.manager;
gr.state = 'Requested';
gr.source_table_new = request.getUniqueValue(); //Assuming this is the sys_id for the source record
gr.source_table = request.getTableName(); //Assuming this is the table of the source record
gr.insert();

},

I'd also avoid call your variables gr and give them meaningful names.

Let me know how you go on.

Thanks

 

Justin