'g_form' not working in Action Assignment in ServiceNow Workspace

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2024 09:26 PM
I am creating an Action Assignment "Update Document Category" for attachment in Incident Table as a part of Service Operations Workspace.
The Action Assignment is of type "Client Script" and the script is as below
function onClick(g_form) {
var ga = new GlideAjax('GetMyChoices');
ga.addParam('sysparm_name', 'getFieldChoices');
ga.getXMLAnswer(function(answer1) {
var answer = JSON.parse(answer1);
fields.push({
type: 'choice',
name: 'u_category',
label: getMessage('Document Category'),
choices: answer.choices,
mandatory: true
});
g_modal.showFields({
title: "Upload Document Category",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setDisplayValue("short_description", fieldValues.updatedFields[0].value);
});
});
}
I am seeing that inside the script g_form object is undefined, and functions like setValue, addInfoMessage, etc not working. Can anyone advise me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2024 02:15 AM
It appears that there's no setDisplayValue within GlideForm API at this line below.
g_form.setDisplayValue("short_description", fieldValues.updatedFields[0].value);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2024 08:36 PM
Hi,
I think the issue is here
function onClick(g_form) {
Onclick doesn't expect any argument. Try with just "function onClick()" .