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:34 AM
Oke clear. How do you know which incident? You do mention an existing incident.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 02:42 AM
Still any help needed? Or did you figure it out already?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 09:58 PM
Hi there,
Did this solve your question? Or do we need to follow-up on this?
Please mark this answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 01:50 AM
Hi Mohammed,
Not sure about your business requirement (why scheduled job) but this can be created as an attachment & attached to the RITM with filled variable details as & when a RITM is submitted.
Look for blog that you may find helpful. This though may require few tweaks but should give you an understanding of how to proceed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2020 02:55 AM
Hello Hyder,
Here is a sample script, which you can try.
var gr = new GlideRecord("sc_req_item");
gr.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()"); //fetches ritms created on today
gr.query();
var contents="";
while(gr.next()) {
contents = contents+gr.getValue("number"); //add more columsn whatever you want here
contents = contents+"\n";
}
var filename = "ritms.txt";//your filename
var gr1 = new GlideRecord("incident");
gr1.get("ff4c21c4735123002728660c4cf6a758")//put your incident sys_id to which you want to attach
//create the attachment
var attachment = new GlideSysAttachment();
attachment.write(gr1,filename,"txt",contents);
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP