
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 10:36 AM
Hello everyone,
I'm trying to create an UI action that will open the sys_user table from a new incident record in the agent workspace, the below script works fine, but it's currently trying to enforce the mandatory fields of the incident record before it'll open up the sys_user table in a new tab, even though it's not saving the incident record when the UI action is pressed. This is an issue because the agent wont be able to fill out all the mandatory fields until they create the new user record from with that UI action.
This UI action will only be active on the agent workspace.
Here's the script i'm using:
var newUser = new GlideRecord("sys_user");
newUser.initialize();
action.openGlideRecord(newUser);
I don't believe it's saving the incident record when the UI action is pressed, so i'm not sure why it's trying to enforce the mandatory fields to open a new workspace tab.
So as of right now i'm just trying to have it not enforce the mandatory fields, but the below line isn't working when I add them in: g_form.setMandatory('caller_id', false);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2020 12:13 PM
I'm not super happy with this because all the mandatory fields are still marked false when the tech goes back to the incident after creating the new user record, but it does work as of now.
Client = true
Script:
// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
serverReopen();
function serverReopen() { //Pulls up blank Sys_user record in new tab
var newUser = new GlideRecord("sys_user");
newUser.initialize();
action.openGlideRecord(newUser);
gs.addInfoMessage(gs.getMessage("Please make sure Contact User, Catagory, Subcatagory, and Assignment group are filled in before saving incident"));
}
Workspace form button = true
Workspace client script:
function onclick(){
//Marks all the mandatory fields false so it can run the server side script.
g_form.setMandatory('caller_id', false);
g_form.setMandatory('u_contact_number', false);
g_form.setMandatory('location', false);
g_form.setMandatory('category', false);
g_form.setMandatory('subcategory', false);
g_form.setMandatory('assignment_group', false);
g_form.setMandatory('short_description', false);
g_form.setMandatory('description', false);
g_form.submit(g_form.getActionName()); //This makes it skip the client side script and run the server side script
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2020 11:57 AM
Okay so the reason the g_form.setMandatory('caller_id', false); wasn't working was because I didn't have the Client checkbox set to true in the UI action.
But I guess because new GlideRecord is server side it's not working when the Ui action is set to client side. Fun fun.
Now I have to figure out how to run the g_form.setMandatory as client and the GlideRecord as Server side.
So i'm trying the below serverReopen script that I found in a different UI action without luck. Anyone got any tips/ideas?
function onClick() {
g_form.setMandatory('caller_id', false);
g_form.setMandatory('u_contact_number', false);
g_form.setMandatory('location', false);
g_form.setMandatory('category', false);
g_form.setMandatory('subcategory', false);
g_form.setMandatory('assignment_group', false);
g_form.setMandatory('short_description', false);
g_form.setMandatory('description', false);
}
// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
serverReopen();
function serverReopen() {
var newUser = new GlideRecord("sys_user");
newUser.initialize();
action.openGlideRecord(newUser);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2020 12:13 PM
I'm not super happy with this because all the mandatory fields are still marked false when the tech goes back to the incident after creating the new user record, but it does work as of now.
Client = true
Script:
// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
serverReopen();
function serverReopen() { //Pulls up blank Sys_user record in new tab
var newUser = new GlideRecord("sys_user");
newUser.initialize();
action.openGlideRecord(newUser);
gs.addInfoMessage(gs.getMessage("Please make sure Contact User, Catagory, Subcatagory, and Assignment group are filled in before saving incident"));
}
Workspace form button = true
Workspace client script:
function onclick(){
//Marks all the mandatory fields false so it can run the server side script.
g_form.setMandatory('caller_id', false);
g_form.setMandatory('u_contact_number', false);
g_form.setMandatory('location', false);
g_form.setMandatory('category', false);
g_form.setMandatory('subcategory', false);
g_form.setMandatory('assignment_group', false);
g_form.setMandatory('short_description', false);
g_form.setMandatory('description', false);
g_form.submit(g_form.getActionName()); //This makes it skip the client side script and run the server side script
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 05:55 AM
Winston,
Came across your post because I'm attempting something similar. You should be able to use this in your workspace client script to get around the mandatory fields temporarily.
g_form.checkMandatory = false;
In this example I'm opening a window directly in the Agent Workspace as opposed to a new tab.
function onClick(g_form) {
g_form.checkMandatory = false;
openPopup();
function openPopup() {
g_modal.showFrame({
url: '/sys_user.do?sys_id=-1',
title: "Add New User",
size: 'lg',
height: '25rem',
});
}
}