How to prevent a Change Record Producer from including attachments to the change record as a work note


Description

The following script line is added by default in every Standard Change Record Producer:

'GlideSysAttachment.copy("' + this.TABLE_NAME_PRODUCER + '", "' + producerId + '", current.getTableName(), current.getUniqueValue());

The above line copies the attachments to the change as a work note into the change record.

Where does this default script come from so we can permanently remove or comment that line avoiding it to be included into newly created Record Producers?

Resolution

There is a function called "_createRecordProducerAndVersion" located within the "System Definition > Script Include", "StdChangeUtilsSNC" script.

In order to avoid newly created Record Producers to contain that copy attachment code, you need to to copy the whole "_createRecordProducerAndVersion" function from the "StdChangeUtilsSNC" script and add it into the Script Include "StdChangeUtils" script.

After doing that you need to remove or comment the line below that will include the attachment into the scriptContent variable.

'GlideSysAttachment.copy("' + this.TABLE_NAME_PRODUCER + '", "' + producerId + '", current.getTableName(), current.getUniqueValue());\n';

Now, once you create a new Record Producer, it will not contain that part of the code.