UI Action (List Choice)-Run script on Client and Server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 08:56 AM
Hello All,
Greetings...
I have created a custom List choice UI action(approve) to approve a list of time cards at one go, before that it should pop a window asking for confirmation (same as we see when try to delete on list). I tried running the UI action script on client and server firstly asking for a confirmation and then approves all the records at once. But it didn't work.
And I've also gone through the "Delete" UI action script it looks pretty complex. Can anyone suggest me a simpler way to get this requirement done.
Thanks in Advance,
Abilash
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 09:20 AM
Delete UI action script is bit complicated but I think you just need a confirmation dialog to accept yes or no. You can utilize below code from the same UI action with some updates and call the function from "OnClick" field on your own UI action
function showListConfDlg(hasCascadeDel, selObjName, delObjList) {
var dlg = new GlideDialogWindow('delete_confirm_list');
dlg.setTitle('Confirmation');
if(delObjList == null) {
dlg.setWidth(300);
} else {
dlg.setWidth(450);
}
dlg.setPreference('sysparm_obj_list', selSysIds);
dlg.setPreference('sysparm_table_name', tblName);
dlg.setPreference('sysparm_has_cascade_del', hasCascadeDel);
dlg.setPreference('sysparm_sel_obj_name', selObjName);
dlg.setPreference('sysparm_del_obj_list', delObjList);
dlg.render();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2014 08:48 AM
Hello,
You can combine client and server side code in UI Action. Please refer below for your reference:
UI Action:
Action Name : ui_action_test
Client : true
Onclick : combTest()
Script:
function combTest(){
//write client side code for example,
var answer = confirm("Do you want to proceed?");
if (answer == true)
gsftSubmit(null, g_form.getFormElement(), 'ui_action_test'');
else
return false;
}
if (typeof window == 'undefined')
callServercombTest();
function callServercombTest(){
//write server side code for example, action.setRedirectURL(gr);
}
Let me know if you have any queries.
Please mark answer as correct/helpful, if it was really helpful
Regards,
Solutioner
Enhance Knowledge NOW@ www.solutioningnow.com
http://www.solutioningnow.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2020 04:01 PM
I know this post is quite old, but in case anyone else is wondering, I could not find this answer anywhere else on Community.
gsftSubmit() will not work from the List view because g_form is not defined, so there is no form element to provide (which is the second parameter required by gsftSubmit()).
GlideList2.action() is an undocumented g_list function that will achieve the same effect on List view as gsftSubmit() does on the Form view. You can use it as follows:
var the_list = GlideList2.get(tablename);
the_list.action(action_id, action_name, selected_record_ids);
Here is a fuller example script, which also shows how to get only the selected sys_ids which are allowed by the UI Action's condition:
Name: Example Action
Sys ID: 0123456789abcdef0123456789abcdef
Table: incident
Action name: example_action
Client: true
Onclick: clientScript()
function clientScript() {
// Do client-side things, like a confirmation popup
// After client-side things are done
var action_id = "0123456789abcdef0123456789abcdef"; // sys_id of the UI Action
var action_name = "example_action" // action_name of the UI Action
var tablename = "incident" // name of the table for this list
// Get the GlideList for this table by its tablename
var the_list = GlideList2.get(tablename);
// Get the checked values which this action is allowed for
// First try checking gsft_allow, fall back on GlideList2.getChecked()
var selected = gel(action_id).getAttribute("gsft_allow");
if (selected === null || selected === "") {
selected = the_list.getChecked();
if (selected === null || selected === "") {
return; // Couldn't find any selected values
}
}
// Re-run the action on the server side
the_list.action(action_id, action_name, selected);
}
if (typeof window == 'undefined')
serverScript();
function serverScript() {
// Do server-side things
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2024 11:49 AM
Does the server function already contain the current object to be able to manipulate it ?
e.g. current.getUniqueValue()
will this sentence be executed for each element selected?