Getting sys_id in server script directly.

Virendra Dwived
Tera Expert

Hi Everyone,

 

Can I use current.sys_id in Script include directly to get sys_id of record. I don't want to send sys_id from Client Side (UI Action) but, want to directly get it on Script include.

 

Thanks in advance.

6 REPLIES 6

Unique45
Mega Sage

Hello @Virendra Dwived ,

 

No! we can't use current.sys_id to get sys_id of the record in script Include. Instead you need to pass sys_id from UI action only.

 

 

Please mark correct/helpful if this helps you!

Maik Skoddow
Tera Patron
Tera Patron

Hi @Virendra Dwived 

basically yes, but the better approach is:

current.getValue('sys_id')

as current.sys_id would result in an additional database query.

 Maik

Robbie
Kilo Patron
Kilo Patron

Hi @Virendra Dwived,

 

Whilst you can use the syntax and current object to obtain the sys_id, please remember what a Script Include is and why it is used. Very high level, a Script Include is used to perform a lookup on the server that we want abstract from the Client layer. Therefore, when calling the Script Include you, of course, need to pass something from the Client in order to perform the lookup on the Server server side - eg a record number (or some unique data point). 

It is here on the Server side and Script Include you can perform a query to obtain the sys_id. 

 

Check the below link and article where theres a good example to obtain the sys_id

 

To help others, please mark this as correct and helpful,

 

Thanks,

Robbie

 

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2...

Ankur Bawiskar
Tera Patron
Tera Patron

@Virendra Dwived 

how and from where the script include is getting called?

Please give some background to your question

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