Getting the SysID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 09:05 AM
I am working on a onLoad Client script. I need help passing in the sysid value. Currently I have is passed in directly but because different evnironments have different sysid that will be a issue. How can I get the sysid of this value with code, rather than passing it directly in.
Here is what I have so far:
function onLoad(){
if(g_form.isNewRecord(){
g_form.setValue('u_category', sysid numbers);
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 09:35 AM - edited 11-15-2023 11:58 AM
To get the sys_id of the current record, try
g_form.getUniqueValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 09:53 AM
Hi @asher14 ,
You can use the "g_form.getUniqueValue()" in place of "sysid numbers" suggested by @Brad Bowman , if you are looking for sys_id of record which is not saved yet , this onLoad will not work for saved record.
Query -> are you adding record's sys_id in category field, is it text field or mapped to Choice[sys_choice] table.
function onLoad(){
if(g_form.isNewRecord(){
g_form.setValue('u_category', g_form.getUniqueValue());
};
}
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution