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.

add an attachment via catalog client script (on load). when i open the form it should add an attachment . i have written the below code but its ot working.

saurabh1
Giga Contributor

function onLoad() {

    //Type appropriate comment here, and begin script below

     

      var cat_id = gel('sysparm_item_guid').value.toString();

     

      //Check if attachment is available

      var gr = new GlideRecord('sys_attachment');

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

      gr.addQuery('file_name','test.dotx');

      gr.query();

      if(gr.next()){

           

              GlideSysAttachment.copy('kb_knowledge','d826f8222d4cda40ac0a45db236a591d', 'sc_cart_item', cat_id);

      }

     

     

     

}

5 REPLIES 5

Can you provide more detail? We are trying to add an attachment in ATF.