Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to use g_modal from an UI Action for Agent Workspace?

americo
Tera Contributor

Hello community,

I'm trying to open a custom component in a Modal window in Agent workspace through a UI Action, you can actually do that as per the docs to use a custom component and call g_modal in a UI aciton to render your component. I have followed the steps in the docs as per below link, just you may need to add admin role to the ACLs in the table sys_aw_registered_scripting_modal 😉

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workspace/task/set-up...

However, I would like to control the buttons in the modal window or pass along some data back from the custom component to the modal window or being able to control the modal from my custom component.

Basically , In my custom component I want to list some categories and base on what is selected to pass back those values to the form, I can pass the g_form object as part of the params values when invoking the g_modal. However, I would like to return or pass this data selected in the child component to the modal component so once the user clicks the button I can validate this in the UI action rather from the child component,  I want to avoid using g_form in my custom component and instead to pass values to it. Another approach I was thinking of is to hide the modal buttons and instead use the buttons from my custom component and be able to close the modal popup from the custom component. Sadly I'm not able to find how to disabled buttons in the modal or pass some reference to my custom component to close the modal. Seems that g_modal has not much information about what options can be configured or pass to it.

Something to mention is that I can pass some parameters to my custom component by specifying those in the params object, think of params as your properties object 🙂 , as per below example:

g_modal.global.showTemplate({
title: 'Response Template',
//confirmTitle:'Copy',
params: {
secondaryItems:{},
table: g_form.getTableName(),
sysId: g_form.getUniqueValue(),
gForm: g_form
}
}).then(function(result){
console.log(result)
alert('confirm:'+result);
}, function(error) {
console.log(error)
alert('cancel:'+error);
});

 

1 ACCEPTED SOLUTION
5 REPLIES 5

arturoma
ServiceNow Employee
ServiceNow Employee

Broken link

arturoma
ServiceNow Employee
ServiceNow Employee

Broken link