How to reference field in another table

Meshia
Kilo Guru

I'm writing a client script that will allow me to send an alert if a value on a dot-walked table is true.  The Client script is being written for the Incident table but need to reference a field in the sys_user table.  What is the correct format for referencing that table via the script below?

Example

 

function onSubmit() {

//Alerts the CMR creator if they try to peer review their own change

var caller_flag = g_form.getValue('caller.u_flagged');

if (caller_flag === true){

alert('You cannot peer review a change that you are creating.','Warning');
return false;
9 REPLIES 9

J_31
Kilo Sage

function onSubmit() {
// Get the sys_id of the caller field
var callerId = g_form.getValue('caller');

// Query for the sys_user record using GlideRecord
var callerGr = new GlideRecord('sys_user');
callerGr.addQuery('sys_id', callerId);
callerGr.query();

// Check the flagged field on the sys_user record
if (callerGr.next() && callerGr.u_flagged === true) {
alert('You cannot peer review a change that you are creating.', 'Warning');
return false;
}
}

Thank you but this isn't working for me.

Prince Arora
Tera Sage
Tera Sage

@Meshia ,

 

The correct way is using "g_form.getReference" but it will not work in the onSubmit client script,
Is it possible to make your client script as onChange, if yes I will assist your further



If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

I can't.  The main objective is to have an alert pop when a user is identified as a flagged user.  I wanted to create a workflow that would annotate the user as flagged in our system based on the number of complaints submitted.  The alert would pull the true or false value from the flagged field in the referenced user's profile if true the Alert would pop up indicating the user has been flagged.