The g_form.getReference doesn't work in Workspace Client Script in a Ui action

MadalinDorG
Tera Contributor

I'm trying to use the g_form.getReference in a ui action in the Workspace Client Script to get a field on the assignement group reference field but it doesnt seem to work, is there an alternative to the getReference for the Workspace client script?

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

Are you using a callback function?

https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/...

Example Code:

function onChange(control, oldValue, newValue, isLoading) {
    g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
 
function doAlert(caller) { // reference is passed into callback as first arguments
   if (caller.getValue('vip') == 'true') {
      alert('Caller is a VIP!');
   }
}

View solution in original post

1 REPLY 1

Brian Lancaster
Tera Sage

Are you using a callback function?

https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/...

Example Code:

function onChange(control, oldValue, newValue, isLoading) {
    g_form.getReference('caller_id', doAlert); // doAlert is our callback function
}
 
function doAlert(caller) { // reference is passed into callback as first arguments
   if (caller.getValue('vip') == 'true') {
      alert('Caller is a VIP!');
   }
}