- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 11:22 AM
Hi,
I am getting records from another instance and storing in custom table using GET Api in scheduled job and set it to run in every 60mins. I want a ui action to be created in list view of custom table so user can click on the button to get the updated records. How can i do that.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 01:51 PM
Another possible solution would be to directly have your REST Call on a function on your script include, then you can simply call your function from the UI Action and update the records based on the returned response.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 11:54 AM - edited 03-11-2025 11:55 AM
Hi @Kumar147 ,
The following script can be used to invoke "Execute Now" on a a scheduled job:
(function(){
var gr = new GlideRecord("sysauto_script");
gr.addQuery("name", "NAME OF YOUR SCHEDULED JOB);
gr.query();
if (gr.next()) {
SncTriggerSynchronizer.executeNow(gr);
gs.log("Scheduled Job executed);
} else {
gs.log("Scheduled Job not found");
}
})();
But since you want to pass some data as per your list selection, I would recommend using "event" rather than "Scheduled Job" as you can pass parameters and the whole operation would be running in the background, so users will not get stuck waiting for the operation to terminate.
- You can create your event from All > System Policy > Events > Registry
- Create a Script Action All > System Policy > Events > Script Action Set the event name to your event created in step 1
- You can set your GET REST Call on the Script Action and access the event parameters as follow:
var selectedItems = event.parm1;
var anotherParameter = event.parm2;
//YOUR REST CALL IN HERE
- Now, on your UI action, you could simply gather the selected rows from your list, and make a GlideAjax to a script include which would trigger the event:
var tblName = g_list.getTableName();
var selSysIds = g_list.getChecked();
var ajaxHelper = new GlideAjax('YOUR SCRIPT INCLUDE CLIENT CALLABLE');
ajaxHelper.addParam('sysparm_name', 'triggerEvent');
ajaxHelper.addParam('sysparm_listids', selSysIds);
ajaxHelper.addParam('sysparm_tablename', tblName);
ajaxHelper.getXML(processResult);
function processResult(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
//DO YOUR LOGIC
}
}
On the function on your script include you can trigger the event
gs.eventQueue('YOUR_EVENT_NAME', current, PARAM1, PARAM2);
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 12:46 PM
Hello @Medi C
Thanks for your response.
If i unchecked the client in ui action its working when i selected any of the record in list view. Similarly i want this to be worked even if i not checked any of the record. Just to refresh the page when i clicked on ui action and to trigger the api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 01:06 PM
Hi @Kumar147 ,
The following can be used on UI Action to reload / refresh the page.
Client unchecked:
action.setRedirectURL(current);
Client checked:
g_navigation.reloadWindow();
You can based if there are items selected on the list to determine if you want to update only the selected records or all of them.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 01:51 PM
Another possible solution would be to directly have your REST Call on a function on your script include, then you can simply call your function from the UI Action and update the records based on the returned response.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.