I need to create a .txt file on click of a scheduled job,can anyone help on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:11 AM
Hi All,
i Have to write a scheduled job which will create a .txt file and attach on the incident record
for example
var a = "test1";
var b = "test2";
once i click on execute its should create a .txt file with the above variables and save it on the incident record..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:23 AM
Hello Mohammed,
You may find below thread helpful.
var attachment = new Attachment();
//attachment.write('TablenameFileToAttach','SysIDOfRecord','Filename','TypeOffile','ContentOfFile')
var attachmentRec = attachment.write('sc_req_item', '19647519db940010343688094896193b', 'TextFile'+".txt", "text", "Test file attached");
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:35 AM
Hi Pradeep,
Basically i need to query all the RITM's that were created today on a specific catalog item, Create a .txt file with all the details of the RITM and save that file on a existing incident..
for testing now, i will store hardcode 2 variables and i need to create a text file and save that file on a existing incident

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:43 AM
Thanks for the update Mohammed. Could you please try with the code shared? i.e query RITM with catalog item and store those variables in one variable and then call Attachment(); to create a text file.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:52 AM
Hi Pradeep,
I tried the below
var attachment = new Attachment();
var a = "hi";
var attachmentRec = attachment.write('incident', 'a1d58956db2094107f62264cd39619e7', 'Test123'+".txt", "text", "' +a + '");
but its not printing the the value stored in the variable a