ys_id values uniquely identify each record in your Service-now instance database. While you should never try to modify these values, it is sometimes useful to know what the sys_id value is for a particular record. This article describes the different ways of identifying the sys_id value for a particular record.
View the sys_id in your browser information bar
Since the sys_id of a record is always part of the URL linking to that record, you can see the sys_id in the information bar of your browser simply by hovering over a link to the record.
So, if the URL for an incident record looked like this…
The sys_id of that record would be this…
Copy URL menu option
The best way to actually retrieve the the sys_id for a record is just to open that record, right-click the header for the record, and select the ‘Copy URL’ menu option. This action can also be taken by right-clicking any record in a list. The sys_id value is the 32-character value immediately after ‘sys_id=’.
Why is the sys_id -1?
A sys_id value of -1 in a URL is not actually a sys_id at all. If you see -1 as the sys_id in a URL, it indicates that a new record form will be displayed from that URL.
More information can be found about sys_id values here.
How can I get the sys_id of the variable in client script.I need to use it in the service portal and get control method won’t help me there.
Unfortunately, ServiceNow hasn’t given us any reasonable way to get to this information. G_form isn’t even available in the Service Portal and the sys_id of a reference field value isn’t stored anywhere at all in the page HTML.