How to delete attachments on data sources though transform script in scoped application

sowmyaj
Giga Expert

Hi All,

        I'm in scoped application "abc", I have data source "abc ds" and transform map "abc tm". When I will attach the document and processed with data load, I need to delete the attachment on data source. So, I have written "on complete" transform script as below,

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

  //clean up attachment from data source once done transforming the data source

  var gr = new GlideRecord('sys_data_source');

  if(gr.get('sys id of data source')){  

  var attach = new GlideSysAttachment();  

  attach.deleteAll(gr);

  }

})(source, map, log, target);

Let me if any one know the solution

Thanks,

sowmya

3 REPLIES 3

Alikutty A
Tera Sage

Hi Sowmya,



Please make sure your scoped application has access to delete records from attachment table.



find_real_file.png


Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


Hi,



        I have given the access but still no result.



Thanks,


Sowmya


Try this in script



var gr = new GlideRecord("sys_attachment");


gr.addQuery("table_sys_id=SYS_ID_DATA_SOURCE");


gr.query();


gr.next();


gr.deleteMultiple();



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response