Follow-up question - Remove prefix from table name in sys_attachment table

kevindang
Tera Contributor

Hi @Ankur Bawiskar.

This is just a follow-up question regarding the script below you posted in https://www.servicenow.com/community/itsm-forum/remove-prefix-from-table-name-in-sys-attachment-tabl.... You asked me to created a new post since this was an old thread.

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var gr = new GlideRecord("sys_attachment");
    gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
    gr.addQuery("table_sys_id", current.sys_id);
    gr.query();
    if (gr.next()) {
        gr.table_name = current.getTableName();
        gr.update();
        // new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id); 
    }

})(current, previous);

Do you know why this line of code is commented for "sc_req_item" table and the attachments still show up on attachment list on top of the record whereas the same line of code needs to be added for "sn_hr_core_case" table for the same reason? Thanks

 

6 REPLIES 6

@kevindang 

I will have to test it out when time permits.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

kevindang
Tera Contributor

@Ankur Bawiskar - Thank you and I'm looking forward to your test results.