Ashley Snyder
ServiceNow Employee
ServiceNow Employee
 Center of Excellence / Workspace / How to use UI Actions in Workspace

 

FYI: This article has not been updated or reviewed since the Tokyo release. Use at your discretion, but be advised that these methods may or may not work on later releases.

 

 

Table of Contents


Overview
Fields and Tables
Call a Server Side UI Action
Unsupported Methods
Methods
GlideAgentWorkspace
g_modal
Show Fields
Show Frame
Alert
Confirm
Confirm Destroy
action.openGlideRecord
Community Resources

 
 

Overview

 

UI Actions are supported in both agent and configurable workspaces, but only in limited areas, such as the Action Bar component which is provided by default on the out-of-the-box record page. This means that UI Actions are only supported on forms in workspaces and not lists. If you have existing UI Actions on forms that you want to port over to your workspace or need to use the same UI Action on both a workspace and in the classic environment, you may be able to modify your UI Action code to do so. The Set up custom UI actions in legacy workspace product documentation has extensive information on creating UI Actions, and most of the information does still apply to both configurable and agent workspaces.

You can use Declarative Actions in the workspace ui on forms, lists, and related lists, and they work with both workspaces and UI Builder pages, so you don’t need to customize an out-of-the-box UI Builder page. For more information see our COE article on Declarative Actions.

 

Fields and Tables

 

There are some main fields and tables you need to know to use UI Actions in configurable workspaces. When using Workspace options ensure the Client checkbox on the UI Action is set to true.

 

  • Workspace Form Button - To make the UI Action appear on the list of UI Actions.
  • Workspace Form Menu - To make the UI Action appear as a list item in the menu associated with UI Actions.
  • Workspace Client Script - This is an optional field used to create a workspace-specific client script. Workspace has similar client scripting limitations as Service Portal.
  • Format for Configurable Workspace (Available in San Diego) - Automatically creates the UX Form Action record needed to link the UI Action to configurable workspaces.
  • UX Form Action - Links a UI Action to use in configurable workspaces.
 

Call a Server Side UI Action

 

Workspaces use client-side UI Actions, and a UI Action must be marked as Client in order for it to appear and function on a workspace. So what do you need to do if you want to re-use a server-side UI Action you've previously created or want to create in a workspace UI Action? You have some choices. You can create a server script Declarative Action for the Workspace, which is detailed in our COE article on Declarative Actions, or you could call the server-side UI Action from your client-side UI Action.

 

Example

 

 

function onClick() {
  var actionName = g_form.getActionName();
  g_form.submit(actionName);
}

 

 

 

 

Unsupported Methods

 

The workspace client scripting environment does not support the following global variables:

  • this, window, document
  • $, $$, jQuery, $j
  • angular

In general, accessing globals is not behavior that should be relied upon. The client scripts should only access the registered objects i.e. documented client side methods within the scripting environment.

 

Methods

 

GlideAgentWorkspace

This is a documented API, for more information on the methods see the documentation on the developer site. The g_aw API enables a UI Action or Client Script to open a specified record in a Workspace tab. Two methods are currently available, see the Close tab and save-and-close tab UI Actions product documentation for specific examples.

closeRecord()

openRecord()

You can also try the undocumented setSectionExpanded method to collapse or expand your sections.

 

Example

 

 

g_aw.setSectionExpanded('Notes', false); // will collapse the Notes section
g_aw.setSectionExpanded('Resolution', true); // will expanded the Resolution section

 

 

 

 

g_modal

A client scriptable API that allows the user to display an overlaid modal window and perform the following:

  • Display input type fields in a modal window
  • Show something else in a frame such as a UI Page or external link
  • Perform action on confirm
  • Load a component

 

Common Properties for Methods

title: The title of the Modal window

size: The size of the Modal window: sm, lg, xl, fw (fixed-width)

height: Height of the Modal window in pixels/em (optional)

 

 

showFields

A g_modal method that displays a modal window with the fields defined in the UI Action Workspace Client Script. Displays the OK and Cancel buttons by default. 

 

Properties

Accepts title, message, and callback as arguments and returns a promise. The fields property is required. If only one argument has been provided it will be treated as a fields parameter.

fields:

name: The name of the field, if using a reference field it is the name of the reference field on the form

type: textarea, choice, reference, boolean, string

label: How the field displays to the user

value: Initial value of the field, useful in choices or booleans

mandatory: true or false

 

If type is reference:

name: The reference field on the current record being used to search

reference: The table you're referencing

referringTable: The table you're referencing from

referringRecordId: The sys_id of the value you're calling in the UI Action form

value: Can use the g_form method here to get the value

displayValue: Display value must be used in conjunction with value

 

 

Example 

This is a simple example of prompting a user for a reason using a modal window, and then passing it back to the Work notes field on the record. In the example below the then() method returns a Promise, which returns what the modal returns such as fieldValues in this example. In this example the work notes field on the client side with the field value are in the updatedFields array. Since only one field is being returned, the index/position was 0. If returning multiple fields just enter the position they are in.

 

 

 

 

function onClick(g_form) {
    g_modal.showFields({
        title: "Enter your reason",
        fields: [{
            type: 'textarea',
            name: 'work_notes',
            label: getMessage('Reason'),
            mandatory: true
        }],
        size: 'lg'
    }).then(function(fieldValues) {
        g_form.setValue('work_notes', fieldValues.updatedFields[0].value);
        g_form.save();
    });
}

 

 

 

 find_real_file.png

 

This example expands on using more fields, such as a choice field and a reference field.

 

 

 

function onClick(g_form) {

    var fields = [{
        type: 'textarea',
        name: 'work_notes',
        label: getMessage('Reason'),
        mandatory: true
    },
        {
            type: 'choice',
            name: 'reason_code',
            label: getMessage('Reason code'),
            value: getMessage(' -- Select -- '),
            choices: [{
                displayValue: 'Duplicate',
                value: 'duplicate'
            },
                {
                    displayValue: 'Canceled',
                    value: 'canceled'
                }
            ],
            mandatory: true
        },
        {
            type: 'reference',
            name: 'caller_id',
            label: getMessage('What is your name?'),
            mandatory: true,
            reference: 'sys_user',
            referringTable: 'incident',
            referringRecordId: g_form.getUniqueValue(),
			value: g_form.getValue('caller_id'),
			displayValue: g_form.getDisplayValue('caller_id')
        }
    ];

    g_modal.showFields({
        title: "Enter your reason",
        fields: fields,
        size: 'lg'
    }).then(function(fieldValues) {
        g_form.setValue('work_notes', fieldValues.updatedFields[0].value);
        g_form.setValue('caller_id', fieldValues.updatedFields[2].value);
        g_form.save();
    });
}

 

 

 

 

find_real_file.png

 

showFrame

A g_modal method to link to external URLs or UI Pages. 

 

Properties

Accepts a title, message, and callback. The url property is mandatory. If only one property is provided it will be treated as a url parameter.

 

Example 

 

 

function onClick(g_form) {
    var kbId = '24d9243187032100deddb882a2e3ec33'; //sysId of KB article
    g_modal.showFrame({
        url: '/kb_view.do?sys_kb_id=' + kbId,
        title: 'Test Knowledge Article',
        size: 'lg',
        height: 500
    });
}

 

 

 

 

find_real_file.png

 

The next example is using a UI Page embedded and uses window.parent.postMessage() in the UI Page to pass data from the iFrame back to the workspace since g_form is not accessible in the UI Page when it is in the iFrame. In your instance or PDI the Propose Major Incident UI Action is a great resource to see how UI Pages are being called in workspaces.

 

 

 

function onClick(g_form) {
	function proposeMIC(data) {
		var workNotes = data.msg + "\n" + data.workNotes;
		var notes = g_form.getValue('work_notes') + ' ' + workNotes;
		var bi = g_form.getValue('business_impact') + ' ' + data.businessImpact;
		g_form.setValue('work_notes', notes.trim());
		g_form.setValue('business_impact', bi.trim());
		g_form.submit('sysverb_mim_propose');
	}
	
	function openPopup() {
		if(!g_form.getControl('work_notes')) {
			getMessage('Cannot propose major incident as "Worknotes" is not visible', function(msg) {
				g_form.addErrorMessage(msg);
			});
			return false;
		}

		var url = "/sn_major_inc_mgmt_mim_propose.do?sysparm_stack=no&sysparm_workspace=" + true;
		g_modal.showFrame({
			title: getMessage("Propose Major Incident"),
			url: url,
			size: 'lg',
			autoCloseOn: 'URL_CHANGED',
			callback: function (ret, data) {
				if (ret)
					proposeMIC(data);
			}
		});
	}
	
	openPopup();
}

 

 

 

In the UI Page within the Client Script the following function is being used to handle the Cancel that you may need to use in your UI Pages as the native Cancel functionality does not work. The config to identify the workspace is set in the HTML.

 

 

 

var config = {workspace: '${JS_STRING:RP.getParameterValue('sysparm_workspace')}' == 'true'};

function close() {
    if(!config.workspace)
        dialog.destroy();
    else
        window.location.href = window.location.href + '&sysparm_next_pg=true';
}

 

 

 

Also, if you log the data object it will return the following:

 

 

 

data: {"msg":"Proposed as major incident candidate","workNotes":"work note note","businessImpact":"business impact note"}

 

 

 

 

find_real_file.png

Alert

Displays an alert to the user when performing an action. See the Confirm example below as an alert is displayed to the message if the user does not meet the requirements.

 

Properties

Accepts title, message, and callback as arguments and returns a Promise. Message is required, if only one argument has been provided it will be treated as a message parameter.

alert: getMessage(Title of the Modal), msg(Text to the user), callback

 

Confirm

Displays a confirmation to the user when performing an action.

 

Properties

Accepts title, message, and callback as arguments and returns a Promise. Message is required, if only one argument has been provided it will be treated as a message parameter.

confirm: getMessage(Title of the Modal), msg(Text to the user), callback

 

Example 

This example is adopted from the End Chat UI Action on an Interaction, and is a good example of using if statements to determine when a user can take an action and performing the action when the user clicks OK versus Cancel for example setting the state of the record to Closed.

 

 

 

function onClick(g_form) {

    if (g_user.userID != g_form.getValue('assigned_to')) {
        g_modal.alert('Only the assigned to can end this action.');
        return;
    }

    var msg = getMessage("Are you sure you want to take this action?");
    g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) {
        if (confirmed) {
            g_form.setValue('state', 'closed_complete');
            g_form.save();
        }
    });

    return false;
}

 

 

 

 

find_real_file.png

 

Confirm Destroy

Similar to the Confirm method, except the confirm button is show as a destructive style. 

 

Properties

Accepts title, message, and callback as arguments and returns a Promise. Message is required, if only one argument has been provided it will be treated as a message parameter.

confirmDestroy: getMessage(Title of the Modal), msg(Text to the user), callback

 

action.openGlideRecord

This is another documented API that is very handy when using UI Actions in workspaces. Instead of using action.setRedirecrURL in the UI Action, action.openGlideRecord can be used instead, and will work for both platform and workspace. 

Example

The following example is a simple server script with the Workspace Form Button and Format for Configurable Workspace options selected. Upon clicking the button the server script will run and open the new record in a sub-tab.

 

 

 

var incGr = new GlideRecord('incident');
incGr.newRecord();
incGr.setValue('caller_id', current.getValue('contact'));
incGr.setValue('short_description', current.short_description);
incGr.insert();
action.openGlideRecord(incGr);

 

 

 

 

find_real_file.png

 

Community Resources

 

We’ll link community articles that use the methods mentioned above as we find them. If you think an article should be listed here please comment.

Replicate choice field on Workspace modal with g_modal by Aare Pujuste

Comments
khadija3
Tera Guru

Hello,

 

Thank you so much for the great article, are you aware of any property to remove the close icon in the popup ?

Regrads

F_lix Dion
Kilo Expert

Hi, thank you for your work. I learned everything I know about g_modal thanks to you and your website!

I've got a question for you. I managed to have my pop up window set up and working perfectly, but I am using it on two different UI Actions ("save" button and "resolve" button). 

As of right now, I duplicated the whole script in both actions so I was wondering if there would be a way to reuse the same code in different UI Actions.

I've tried with UI Script, Script Include and with gsftSubmit(null, g_form.getFormElement(), 'sysverb_ws_save'); but nothing seems to be working ...

Any suggestions?

Thank you!

F_lix Dion
Kilo Expert

Hi @Ashley Snyder,

Thank you so much for the content on the g_modal.

Quick question: I've been looking around and can't find anything to help me figure it out.

I set up my g_modal window to pop-up when an incident is set to resolved and everything works well, but I would like to add an action when the Agent clicks on Cancel or "X".

find_real_file.png

In fact, I want to refresh the page so that if they cancel, it will cancel the changes and trigger the g_modal again when they will hit resolve again.

As of right now, if an agent clicks cancel, the window closes but the form stays and if you hit resolve again, the data policy kicks in and show an error message instead of having the g_modal pop-up again.

find_real_file.png

Thank you for your time!

F_lix Dion
Kilo Expert

My colleague found a solution so I thought I'd leave it here for people that are trying to do the same:

g_modal.showFields({
title: "Complétez les champs obligatoires pour poursuivre",
fields: fields,
size: 'lg'
}).then(
function(fieldValues) {
g_form.setValue('close_code', fieldValues.updatedFields[0].value);
g_form.setValue('close_notes', fieldValues.updatedFields[1].value);
g_form.save();
},
function(error) {
location.reload(); //to refresh the page if "cancel" or "X" is clicked
});
Ryan66
Tera Contributor

I may have completely missed it, but is there any guidance if we want to simply migrate "old" UI Actions from the legacy backend view to WEP Workspaces?  In our case, specifically Service Operations Workspace.  I love the examples you have and will definitely be using those at some point, but we are starting very basic and just intend to migrate old UI Action functionality to SOW.

 

Thanks again for this post!

F_lix Dion
Kilo Expert

Here is how I did it:

g_modal.showFields({
                    title: "Complétez les champs obligatoires pour poursuivre",
                    fields: fields,
                    size: 'lg'
                }).then(function(fieldValues) {
                        g_form.setValue('close_code', fieldValues.updatedFields[0].value);
                        g_form.setValue('close_notes', fieldValues.updatedFields[1].value);
                        g_form.save();
                    },
                    function(error) {
                        location.reload();
                    });
Ashley Snyder
ServiceNow Employee
ServiceNow Employee

@Ryan I've updated this post to cover some more of this question. Migration will really depend on what types of UI Actions you're using and the code/methods utilized in those UI Actions. If you're migrating server-side UI Actions, those may be pretty straightforward and can either be migrated to Declarative Actions or called from a Workspace client UI Action.  For client actions that display UI pages, etc. those are the more complex use cases that I detailed in this article and will take some testing and remediation to get the code working in workspaces.

Ashley Snyder
ServiceNow Employee
ServiceNow Employee

@khadija There is not a property to remove the close icon in the pop-up at this time.

Ashley Snyder
ServiceNow Employee
ServiceNow Employee

@Félix Dion there is not a way to do that with the showFields methods at this time. More than likely you would need to implement a UI Page that has some logic that kicks off when the user clicks the cancel button.

F_lix Dion
Kilo Expert

It worked by adding this:

function(error) {
  location.reload();
});

Thank you.

Monika Bhoyate1
Tera Contributor

Hi Ashley,

Thank you for wonderful article. I have a requirement to show check boxes on the form. These checkboxes visibility is dependent on choice field. Can you pls help me understand how this can be achieved?

Regards,

Monika

Pradeep14
Tera Contributor

Hi @Ashley Snyder ,

We are trying to implement the Glide Modal for our Suspend UI Action on HR case form, we have customized the Suspend functionality and we have a date field there, how to achive this using the Glide Modal method or any other way for acheiving this in HR Configurable workspace ?

find_real_file.png

Shambhu K B
Giga Guru

Hi @Ashley Snyder : the article is very helpful. Although I have two use cases as below.

1. Need to display the choice field depending on the value of the other choice field.

2. Need to display the date field.

Can you please guide on how this can be achieved?

I tried with following code, but did not work

{
					type: 'date',
					name: 'follow_up_date',
					label: getMessage('Date'),
					mandatory: true
				}

 

Regards,

Shambhu

Preeti Singh
Kilo Contributor

Hi Ashley Snyder ,

Can you tell me how can i change the Suspend Reason title of this pop-up? 

i am not able to find out can you help?

Aivaras Gon_aro
Tera Contributor

Hello,

 

Is there a way to show textarea fields that support html as part of g_modal without creating custom component?

Or if we choose to create one, what is the easiest way to replicate Comments/Worknotes behavior in modal window?

leboute
Tera Contributor

Kudos. Once I grasped the essential "non-blocking" nature of UX client-side API methods, all things started to make sense. 

mahmoud5
Tera Contributor

Hi @Ashley Snyder,

I tried this but not saving the form changes after submit it closes the modal but g_form.save() not working fine in the workspace, can you help ?

 

function onClick(g_form) {
if(g_form.getValue('comments') == ''){
var choice = [{
type: 'choice',
name: 'called',
label: getMessage('Called Beneficiary'),
value: getMessage('-- Select --'),
choices: [{
displayValue: 'تم الرد',
value: 'true'
},
{
displayValue: 'لم يتم الرد',
value: 'false'
}
],
mandatory: true,
}];

g_modal.showFields({
title: "Beneficiary called ?",
fields: choice,
size: 'lg'
}).then(function(selection) {
if ( selection.updatedFields[0].value == 'false') g_form.setValue('work_notes','لم يتم الرد');
else g_form.setValue('work_notes', "تم الرد");
g_form.save();
},
function(error) {
location.reload();
});
}
else {
g_modal.confirm("Are you sure?").then(function (confirm) {
g_form.setValue('work_notes', g_form.getValue('comments'));
g_form.save();
},
function(error) {
location.reload();
});

}

}

Hariskanthini
Tera Contributor

Thank you for this wonderful article! Helped me so much. 😀

Ihor Kochetkov
Tera Contributor

@Ashley Snyder kudos, that's helpful. Any options how to add date/time picker to modal window?

@Pradeep14 did you guys find something?

dhananjay21
Giga Guru

@Ashley Snyder Can you please let me know how can we override the reference qualifier for the below, for example if we need to show only active users or any filtration without updating the reference qualifier of caller_id field.

 

{
            type: 'reference',
            name: 'caller_id',
            label: getMessage('What is your name?'),
            mandatory: true,
            reference: 'sys_user',
            referringTable: 'incident',
            referringRecordId: g_form.getUniqueValue(),
			value: g_form.getValue('caller_id'),
			displayValue: g_form.getDisplayValue('caller_id')
        }

 

dhananjay21
Giga Guru

@Ashley Snyder  Also how can we increase the number of records shown in a reference field. As it seems the limit is only 250.

dhananjay21_0-1683101994587.png

 

 

Amrutha Matt
Tera Contributor

How do I close all related tasks by clicking on UI button on parent form in workspace ,which shows pop up ,once user confirms it should close tasks

Arjun11
Tera Contributor

@Ashley Snyder 

This article is a rare find! Thanks for writing it.

"Instead of using action.setRedirecrURL in the UI Action, action.openGlideRecord can be used instead, and will work for both platform and workspace"

A few of the UI actions we've created worked fine when we ticket "Format for configurable workspace" even it included the action.setRedirectUrl. Many of the OOB UI actions that came for the workspace contained such code.

My question is :

- Do I have to replace action.setRedirectUrl, with action.openGlideRecord wherever it's used?

- Do we have a workspace client script - to rewrite the functionality of onClick? or what's the functionality of this vs Client checkbox + onClick script?

- Do we have to call the onClick -  "Call Server Side UI Action" for all the UI Actions? Asking this because, even without calling the actionName from the workspace client script, UI actions on the configurable workspace are working. For eg: You can check the "Assign to Me" button on the CSM case table

 

jmcagod
Kilo Guru

hello @Ashley Snyder ,

 

Is there a way to pass values to url then use it in the g_modal?

I am trying to open a new form that is from a different table, and need to pass values from the current record (where UI action is displayed)

 

Thanks!

IndianaJones
Tera Expert

@Ashley Snyder 

 

I am stuck on why my model is not calling the server side UI action after the modal has been submitted. I used a basic confirm prompt and it works fine, but it doesn't do anything if I use a modal. Any help would be greatly appreciated! 

 

code below:

 

function onClick(g_form) {
    //this does not work?
    // var msg = getMessage("Are you sure you want to transfer this to a case? This will auto close the Incident and create a new case record.");
    // g_modal.confirm(getMessage("Confirmation"), msg, function(confirmed) {
    //     if (confirmed) {
    //         var actionName = g_form.getActionName();
    //         g_form.submit(actionName);
    //     }
    // });

    //this does work
    var usrResponse = confirm('Are you sure you want to transfer this to a case? This will auto close the Incident and create a new case record.');
    if (usrResponse == true) {
        var actionName = g_form.getActionName();
        g_form.submit(actionName);
    }
}

 

 

 

IndianaJones
Tera Expert

In my post above, I finally figured out my issue. For some reason the usual way to call the UI action to run server side is getting lost on the confirmation of the modal. Once I directly called my UI action again, it worked just fine on workspace. Any knowledge as to why that is happening would be great to know.  

 

//this was returning "none" in workspace. 

var actionName = g_form.getActionName();
g_form.submit(actionName);

 

Link to my fix. 

https://www.servicenow.com/community/developer-forum/custom-ui-acton-ui-modal-is-not-running-code-af...

Saurabh Chamol1
Tera Contributor

Can we Add attachments via g_modal.show fields?

 

SaurabhChamol1_0-1693363284696.png

 

Diogo Ramos
Giga Sage

I'm just going to leave this one out here, as it might be helpful for someone. 

If you are building a dialog with g_modal.showFields there are some more properties available that were not covered on this article, for example: 

confirmTitle: getMessage('Open') // Allows to change the label of the confirm button in the dialog
cancelTitle: getMessage('Cancel') // Allows to change the label of the cancel button in the dialog
cancelType: 'unstyled', // seems to be a kind of form style of the button can be primary / destructive /
confirm/ default
confirmType: 'destructive ' / seems to be a kind of form style of the button can be primary / destructive /
confirm/ default
instruction: getMessage("dialogMessage") // just add a small label of text within the modal before the fields


I hope it helps. 

Cheers!

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Ashley Snyder 

I want to show only reference field with sys-user record on popup. I have tried below code but not luck

{
type: 'reference',
name: 'assigned_to',
label: getMessage('Assigned To'),
reference: 'sys_user',
 
}
Can you please help us with this.
anupamg
Tera Guru

Hi

This article is very helpful and useful.

I am using it to update status field in Legal Requests and populate custom field with Individual user from Sys_user table.

I am getting into an issue with g_form.save(). 

Although onClick Workspace client script populates the fields on Request as expected but when hit save button it does not save the new values. In log files I could see an error : Requested URI does not represent any resource: /sn_dt/v1/dynamic_translation/is_enabled: no thrown error

Not sure what am I missing 

function onClick(g_form) {

   g_form.setValue('state', 50);// state as Awaiting response from Individual...

   var fields = [{

      type: 'reference',

        name: 'u_awaiting_response_from_individual',

        label: getMessage('Enter Individual Name'),

        mandatory: true,

        reference: 'sys_user',

        referringTable: 'sn_lg_ops_request',

        referringRecordId: g_form.getUniqueValue(),

        value: g_form.getValue('u_awaiting_response_from_individual'),

        displayValue: g_form.getDisplayValue('u_awaiting_response_from_individual')

 

    }];

    g_modal.showFields({

        title: "Awaiting response from Individual...",

        fields: fields,

        size: 'md'

    }).then(function(fieldValues) {

        g_form.setValue('u_awaiting_response_from_individual', fieldValues.updatedFields[0].value);

        //    g_form.save();

           });

}

 

Any help in this regard is greatly appreciated.

Thanks

Anupam

Azhar Tamboli
Tera Contributor

My form is not updated with the reason, I can not find error

here is script

function onClick(g_form) {
    g_modal.showFields({
        title: "Enter your new risk justification",
        fields: [{
            type: 'textarea',
            name: 'comments',
            label: getMessage('Risk Justification'),
            mandatory: true
        }],
        size: 'lg'
    }).then(function(fieldValues) {
        g_form.setValue('comments','this works atlast');// fieldValues.updatedFields[0].value);
        g_form.save();
    });
}
Community Alums
Not applicable

@Ashley Snyder    We've upgraded from Tokyo to Vancouver, and it appears that the return value to the callback function when the autoCloseOn is used, is now false, so the way we had it setup with only doing a redirect in the target window is no longer working.

 

UPDATED  - ISSUE RESOLVED

It appears whatever was causing the result to be true after autoCloseOn is not occurring, but there is a better way to do it.    The UI Action will have the same code, but in the UI Page / Widget on a portal page you are calling there needs to be additional logic to pass back the correct values.

 

For OOB example:  UI Action 'Propose Major Incident' / and UI Page  mim_propose

 

Main steps are setup UI action as above:

  

 

g_modal.showFrame({
			title: getMessage("Propose Major Incident"),
			url: url,
			size: 'lg',
			autoCloseOn: 'URL_CHANGED',
			callback: function (ret, data) {
				if (ret)                 ///  This used to run if the window Auto  Closed on URL change					 
                                      proposeMIC(data);
			}

 

 

In the UI Page or Widget that is embedded you have to add the script that is found in the mim_propose UI Page (lines 46-89), which defines the function iframeMsgHelper and paramaters.

 

Then in the Client Controller/Client script of the UI Page or Widget that is embedded, you can call the function when needed to close the window.

 

iframeMsgHelper.confirm({
      msg: msg,
      workNotes: notes,
      businessImpact: bi
});

This returns true as the "ret" volume referenced above, then also returns the array as the data object in the UI action

There are other options in the function for  '.cancel', which I assume would return a false.

 

Hope this will help someone out.

Alon Grod
Tera Expert

@Ashley Snyder Is there any way of prompting a user for a reason using a modal window, but using a List type field so the user can choose for example multiple groups and populate a list type field on the incident form ?

Alon Grod
Tera Expert

@Community Alums @Kalyani Jangam1 

Is there any way of prompting a user for a reason using a modal window, but using a List type field so the user can choose for example multiple groups and populate a list type field on the incident form ?

Somnath_snow
Tera Contributor

@F_lix Dion Hi!,

Can you please enlighten of 'How just create a cancel button to cancel a incident in any state. It should stay on the same page after cancellation". 

Will be grateful for any help.

 

amol_joshi
Tera Contributor

How to script a glideAjax from workspace client script?

 

Sateesh12
Tera Explorer

Hi,

 

How to use action.setRedirectURL() in server side script here

amol_joshi
Tera Contributor

@Sateesh12       I think if you return false it returns to the original page.

ChinchillaMoMo
Mega Guru

Hi @Ashley Snyder  and the community,

 

Tried this with UI Action, it works beautifully but then, I wanted to make this available as a button on list, so I created a List action with implemented as Client Script which is same as the UI Action workspace section's script. The pop up shows but then it won't save or display the filled in form as next step, anyone knows how I can close this gap?

 

It is not necessary to save the form, it would be best to show the form after pop up (which I am creating a choice list for user to choose), and then user can continue filling up other form details and then hit save.

 

many thanks!

prakhar_yadav
Tera Contributor

In sc_req_item table, we have "Responses" button in form view which opens a template popup and we have same button in our workspace as well, but after clicking that button, nothing happens. I want same popup functionality as it is behaving in form view. I am attaching screenshots of UI actions so that I can get my problem resolved.

 

I think we need to do write script in Workspace Client script, but exactly what should we write there?

 

@Ashley Snyder if you can help please

niveditakumari
Mega Sage

Hi @Ashley Snyder

 

I have ui action button Transfer to IT in platform view on HR case form and when user click on that button dialog box has been opened and when user select assignment group and check that checkbox that HR case is cancelled and new incident is getting created and same thing I need to achieve on agent workspace view and we have added Transfer to IT ui action button in agent workspace and when we click on that nothing is happening. 

Please find attached screenshot : 

niveditakumari_0-1713991386919.png  

 

niveditakumari_1-1713991403619.png

 

 

niveditakumari_5-1713991582783.png 

 

After clicking on Transfer to IT button dialog box is opening 

niveditakumari_3-1713991443503.png

 

niveditakumari_4-1713991455210.png

 

Can anyone please help me to achieve same functionality which we have in platform view. 

 

Regards, 

Nivedita 

 

 

ABC6
Tera Contributor

What if we want to print list view via model,would it be possible to achieve

ElSalmiito
Tera Contributor

I am trying to bypass all the mandatory fields when cancelling the Change request but it still gives me an an error "The following mandatory fields are not filled in:". This is my script below. Can someone help me.

ElSalmiito_0-1714725656067.png

 

-O-
Kilo Patron
Kilo Patron
bypass all the mandatory fields

You should configure mandatory policies correctly instead: so that fields that don't need to be mandatory in state "Cancelled" are not mandatory in state "Cancelled".

Prajwal_
Tera Contributor

Is there a way to close the showFrame g_modal on change of some field. I'm using a loading page url in the g_modal:showFrame until I fetch the values from the backend. I need to autoClose this frame when the values are fetched.

Please let me know if anyone has a solution for this. Thanks!

 

tpeleg
Tera Expert

Is threre a way to save and close a new record  (custom ui action) in agent workspace?

this code is working only for exist records:

 

function onClick(g_form) {
    g_form.save().then(function() {
        g_aw.closeRecord();

    });
}
 
Thanks,
Tomer
Ketan Pandey
Tera Expert

Hi All,

 Has anybody come across such requirement where we have to open the Modal Component with repeater to show list of list contact details. This Modal component to opened when the field called "Affected Site"[reference ]  got selected .

 

Thank You,

Ketan

Vedika29
Tera Contributor

Hello 

We have configure the UI Action Speak w/a  for AWS when it is clicked it shows the UI page with variable actions, contact which is populated from the case form . For the watch list variable we are able to configure the field it shows all the watchlist users that are selected on the case form so we are working on the requirement that user should be able to select only one user from the watchlist members that are added on the case form.

Please find the screenshot for the same.

Vedika29_0-1725292172883.png

 

 

smitaD
Tera Contributor

Hello @Ashley Snyder 

I have tried the below code for watchlist field, I have got the values on agent workspace ui page too but not in list view Could you guide me on this?

 

type: 'reference',
            name: 'caller_id',
            label: getMessage('What is your name?'),
            mandatory: true,
            reference: 'sys_user',
            referringTable: 'incident',
            referringRecordId: g_form.getUniqueValue(),
			value: g_form.getValue('caller_id'),
			displayValue: g_form.getDisplayValue('caller_id')

 

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Ashley Snyder How can I add a reference qualifier on below reference type field. please have a look at my code

           {
            type: 'reference',
            name: 'caller_id',
            label: getMessage('What is your name?'),
            mandatory: true,
            reference: 'sys_user',
            referringTable: 'incident',
            referringRecordId: g_form.getUniqueValue(),
            },

  

Version history
Last update:
‎09-26-2023 06:33 AM
Updated by:
Contributors