Skip to content

Instantly share code, notes, and snippets.

@thisnameissoclever
Last active January 23, 2022 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save thisnameissoclever/487c584367184f2b5eaa32acbee44bef to your computer and use it in GitHub Desktop.
Save thisnameissoclever/487c584367184f2b5eaa32acbee44bef 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