How to pass a list value to another list in UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 10:44 PM
Hi,
Reference the record name of table 1 in table 2's form. I want to use it to query and add the values from the list in table 1 to the list in table 2.
but i can't do this.
Is-he possible to do this ?
Tabale1
name:table1_list_name Type:string
name:table1_list Type:list Reference:sys_user
Table2
name:table1_list_name2 Type:string
name:table2_list Type:list Reference:sys_user
UIPoricy
Conditon
tabale1_list_name2 is not null.
True
function onCondition() {
var userList = new GlideRecord('table1');
var user_array = [];
userList.addQuery('table1_list_name','=',current.table1_list_name2);
userList.query();
user_array.push(userList.table1_list.toSting());
current.table2list = user_array;
}
False
function onCondition() {
var user_array = [];
current.tabele2_list = user_array;
}
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 11:13 AM
@ryo200 Since the UI Policy executes at the client side, you should use GlideAjax, instead of a GlideRecord call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 11:57 AM
@ryo200 i would suggest to use client side onload or on change based on requirement and use Script include and call that with glide
----------------Script include---------------------
getUserDetails: function() {
var id = this.getParameter('sysparm_userID');
var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', id);
grUser.query();
var usrobj = {};
while (grUser.next()) {
usrobj.email = grUser.name.toString();
}
return JSON.stringify(usrobj);
},
Client script:
-------------------------------------ON LOAD-----------------------------
function onLoad() {
//Type appropriate comment here, and begin script below
var request = g_form.getValue("requested_for");
var ga = new GlideAjax("script include name");
ga.addParam("sysparm_name", "getUserDetails");
ga.addParam("sysparm_userID", request);
ga.getXML(userDet);
}
function userDet(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var res = JSON.parse(answer);
g_form.setValue("field name", res.name); // User name
}
---------->mark if its helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 07:01 PM
Entering script include seems to cause errors in function and return.
I have made the following changes, but they do not work properly.
script include
var getUserDetails = function() {
var id = this.getParameter('sysparm_userID');
var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', id);
grUser.query();
var usrobj = {};
while (grUser.next()) {
usrobj.email = grUser.name.toString();
}
return JSON.stringify(usrobj);
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 07:01 AM - edited 10-13-2023 07:02 AM
use script include in this format (this is a sample for your reference) make sure it has client callable
--------------------------------------------------------