Attachment not getting added to Data Source on submit of Request from service catalog.

ankurkhare
Kilo Contributor

I am trying to create a data Source from run script in workflow. The data source record is getting created but the attachment is not getting added from the service request once we submit the request along with attachment. Please assist.

Below is my code which I wrote in run script:

var gr=new GlideRecord('sys_data_source');
gr.name=gs.getUserDisplayName();
gr.import_set_table_name='u_source_data';
gr.file_retrieval_method="Attachment";
gr.type="File";
gr.format="Excel";
gr.header_row=1;
gr.sheet_number=1;
gr.insert();

The above code creates the record in data source form but the attachment is not there.

 

BR,

Ankur

 

1 ACCEPTED SOLUTION

No,

the sysID is a variable in the line...please do not put '' around it.

GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', sysID);

Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

6 REPLIES 6

There is an error in your script, please try the following:

var gr=new GlideRecord('sys_data_source');
gr.name=gs.getUserDisplayName();
gr.import_set_table_name='u_source_data';
gr.file_retrieval_method="Attachment";
gr.type="File";
gr.format="Excel";
gr.header_row=1;
gr.sheet_number=1;
var sysID = gr.insert();
GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', 'sysID');

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

No,

the sysID is a variable in the line...please do not put '' around it.

GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', sysID);

Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!