Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideSysAttachment.copy isn't working

Mussie
ServiceNow Employee
ServiceNow Employee

Hi Guys,

I am not sure why but GlideSysAttachment.copy isn't working for me. There is a requirement where I need to copy the attachment of a requested item into a catalog task for a specific catalog items and this isn't working. I already tried using background scripting and it isn't working either:

Type - Business Rule

Runs on - sc_task

When - after, insert

function onAfter(current, previous) {

    //This function will be automatically called when this rule is processed.

  gs.log('request item sys_id ' + current.request_item);

  gs.log('catalog task sys_id ' + current.sys_id);

  var gr = new GlideRecord('sys_attachment');

  gr.addQuery ('table_sys_id', current.request_item);

  gr.addQuery ('table_name', 'sc_req_item');

  gr.query();

  if (gr.next()){

  gs.log('record found');

  GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_cat_task', current.sys_id);

  }

}

Could you please review and see if I am missing something?

Mussie

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

In other words... line 14 will be:



GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);


View solution in original post

9 REPLIES 9


bernyalvarado
Mega Sage

In other words... line 14 will be:



GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);


I hope this helps!


Mussie
ServiceNow Employee
ServiceNow Employee

Thanks Berny, I don't know how I missed that...I have probably checked this more than 20 times :-).


lol. No worries...! That happens to all of us



Thanks,


Berny