Forked from thisnameissoclever/global.getAttachmentStringByName.js
Created
May 26, 2020 05:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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