The CreatorCon Call for Content is officially open! Get started here.

Schedule job's sys_id from the Script area of the Scheduled Job

Raji10
Tera Contributor

Hi All,

I have a scheduled job which will create an attachment in the same job record, is there any other way to get the sys_id of the scheduled job from its own script area:

The below script is hardcoded with the Scheduled job sys_id :

var attach=new Attachment();
		var tablename='sysauto_script';
		var sysid = '9506eab2dbac84506422138b4b9619b2';
		
		var attachment = new GlideSysAttachment();
		var agr = attachment.getAllAttachments(tablename, sysid);
attach.write(tablename,sysid,"SN1241_number_of_records.html", 'html', msg);

Is it possible to use any object or API to get the sys_id of the Scheduled job from its script area?

1 ACCEPTED SOLUTION

Matt Taylor - G
Giga Guru

Have you tried using current.getUniqueValue()?

View solution in original post

2 REPLIES 2

Allen Andreas
Tera Patron

Hi,

You can try: getUniqueValue

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_ScopedGlideRecordGetUniqueValue

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Matt Taylor - G
Giga Guru

Have you tried using current.getUniqueValue()?