Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pchaozhong/8a549140dd7e7aa479c014b753d9df1a to your computer and use it in GitHub Desktop.

Select an option

Save pchaozhong/8a549140dd7e7aa479c014b753d9df1a to your computer and use it in GitHub Desktop.
Get the string value of an attachment (which must be a text-formatted file, like .txt, .csv. or .xml) in ServiceNow
var tableName = 'incident';
var sysIDOfRecord = '755d52b137b0b30090b68cf6c3990e6f';
var fileNameSansExtension = 'example text doc'; //Full file name: example text doc.txt
var grRecordWithAttachment = new GlideRecord(tableName);
grRecordWithAttachment.get(sysIDOfRecord);
var gsa = new GlideSysAttachment();
//ONLY works in global
var textVal = gsa.get(grRecordWithAttachment, fileNameSansExtension);
gs.print(textVal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment