- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 01:24 AM
Hi,
I want to set the value I get in the script include in the UI action.
A target_group is a type that refers to a cmn_department.
I just want to return the value I got in the script include here.
How can I write?
Following code doesn’t work : UI Actions
current.target_user = gs.getUserID();
function confirmCreate() {
var ga = new GlideAjax('scriptincludename');
ga.addParam('sysparm_name', 'getUserDepartmentList');
ga.addParam('sysparm_id', g_form.getValue('target_user'));
ga.getXML(updateCampus);
}
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
gsftSubmit(null, g_form.getForElement(), 'copy_release');
}
if (typeof window == 'undefined')
current.target_group = doCreate();
function doCreate() {
new scriptincludename().getUserDepartmentList();
}
current.update();
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 01:44 AM
You do not need to include client side code in UI action, only server side code is enough. Please use similar code in the UI action.
current.target_group = new scriptincludename().getUserDepartmentList(gs.getUserID());
current.update();
In the script include function, use the user id to perform appropriate search and return value which you want to set in target_group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 01:44 AM
You do not need to include client side code in UI action, only server side code is enough. Please use similar code in the UI action.
current.target_group = new scriptincludename().getUserDepartmentList(gs.getUserID());
current.update();
In the script include function, use the user id to perform appropriate search and return value which you want to set in target_group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 01:50 AM - edited 10-06-2022 02:08 AM
Hi,
Thank you.
I worked it.
Best Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2024 12:32 PM - edited 01-20-2024 12:34 PM
Hi @Mi1 - as Arpit mentioned, only the server side code is needed in the UI Action script.
You can pass in the User ID (using gs.getUserID) to the script include as a parameter, perform the logic in the script include, and then return it back to the UI Action and set the target_group.
Please mark Correct or Helpful if my response helped you.
You can also find a full guide for how to call a script include from UI Action here.