Create scripted filters
The condition builder alone cannot create some filters, such as displaying a record set that depends on an unrelated table. If you know JavaScript, you can create JavaScript functions for use in advanced filters.
시작하기 전에
Role required: admin
프로시저
예
The company creates an application, Intensive Care, and a table, [u_intensive_care]. While the table contains a reference field for the customer name, there is no direct link to the user table. Thus, the manager cannot set up an incident list filter using the condition builder for customers who are under intensive care.
The solution is to write a JavaScript function that uses a GlideRecord query to build an array of user sys_ids in the [u_intensive_care] table, as shown in the sample code below. Call the function from the condition builder in
the Incident table ([Caller] [is] [javascript:myFunction()]).
function myFunction(){
var arrUsers = [];
var gr = new GlideRecord('u_intensive_care');
gr.query();
while(gr.next()){
arrUsers.push(gr.u_customer.toString());
}
return arrUsers;
}