How to reference field in another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 11:22 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 11:38 AM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 09:15 AM
Thank you but this isn't working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 09:19 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 09:29 AM
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.