- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2019 03:02 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2019 06:42 AM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2019 06:41 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2019 06:42 AM
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!