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.

Copy attachment from "sys_attachment" to scoped app table.

devashishku
Tera Contributor

Hi all,
I am stuck with a problem from past few days that, my all the attachments are stored in "sys_attachment" table and i want to add the same attachment to the record of "x_dmcso_oneview_question_answer" table. 

As, i have to integrate the feature in Ui Builder, so first testing on background script. But the attachment is not getting copied.

var sourceTable = 'sys_attachment';
        var sourceSysId = ''fa1702412bb0f250dcf1f865ce91bfdb";
        var targetTable = 'x_dmcso_oneview_question_answer';
        var targetSysId = '3305ff953b953610079a8c9aa4e45a2c';

        var gsa = new GlideSysAttachment();
        var recordId = gsa.copy(sourceTable, sourceSysId, targetTable, targetSysId);

When I run the script, it is saying 
devashishku_0-1764276474064.png

also checked with switching the scope to global, same message is getting displayed and record is not attached to the other table.

If there will be any solution related to this, please let me know. 

Thanks,
Devashish

 

0 REPLIES 0