UI Action script is unable to read the sys_id of incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 11:22 PM
I have created a UI Action on incident table .in UI Action Script i have written the below
var incident_sysid=g_form.getValue('sys_id');
alert(incident_sysid);
it returning null value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2023 11:46 PM - edited 08-27-2023 11:48 PM
Hi @Ketan Pandey ,
you need to use the getReference Function, but as you need to query data from Backend this method should be used asynchronous by using a callback function.
g_form.getReference('caller_id', doAlert); // instead of caller_id use name of field for which you want to have the record. doAlert is our callback function
function doAlert(caller) { // reference is passed into callback as first arguments - type is GlideRecord
if (caller.getValue('vip') == 'true') {
alert('Caller is a VIP!');
}
}
Greets
Daniel
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 12:01 AM - edited 08-28-2023 12:02 AM
if you want to do it for the sys_id of the incident self, you can also use GlideRecord asynchronous, but check if this is really needed or maybe a Before Query Business Rule with g_scratchpad can provide the information you need. There are for sure better ways - but for that we need more information, what you want to achieve.
function onClick() {
var now_GR = new GlideRecord('incident');
now_GR.addQuery('sys_id', g_form.getUniqueValue());
now_GR.query(response);
function response(result) {
if(result.next()) {
alert(result.getValue('number'));
}
}
}
Greets
Daniel
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 12:01 AM
Hi @Ketan Pandey ,
Now here suppose caller field is reference and I want it's display value then I can use code as below :
function doSubmit(){
var incident_sysid=g_form.getUniqueValue();
var callerDetails= g_form.getDisplayBox('caller_id').value;
alert(callerDetails);
}