How to get sys_id of Script in code.

Geoffrey Bishop
Tera Contributor

Hello, ServiceNow Gurus,

Say I have a Business Rule, and that Business Rule calls into a Script Include, and that Script Include writes a message to the System Log...

Is it possible for the script include to figure out, at runtime, its own sys_id?  And include that in the log statement?

I know that I can manually log the sys_id by writing my own log function and passing in the "hard-coded" sys_id, but that's not what I want.  I want for the script itself to magically determine the sys_id of the container it lives in.  Is that possible?  And if so, how please?

Thank you!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

no you cannot get the sysId of the BR automatically and log it.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

no you cannot get the sysId of the BR automatically and log it.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar Thanks, Ankur.  If you can tell me WHY it's not possible, or explain in a little more detail, I'll mark your answer as the "Correct Answer".  : )

Hi,

Because ServiceNow doesn't provide any OOB object which can access the current BR sysId during it's execution.

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I believe you, but I wonder how you know this.