Contents Now Platform User Interface Previous Topic Next Topic Create scripted filters Subscribe Log in to subscribe to topics and get notified when content changes. ... SAVE AS PDF Selected Topic Topic & Subtopics All Topics in Contents Share 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. Before you beginRole required: admin Procedure Create a new script include. Navigate to System Definition > Script Includes. Click New. Fill out the form, and then select Submit. Open the script include and, in the Script field, create a JavaScript function that returns an array of sys_ids. Ensure that the function uses the same name as the script include. Ensure that the script include is Active and Client callable. Call the JavaScript function from the condition builder. For more information, see GlideRecord queries and Script includes. ExampleA company provides intensive care for a group of customers. To track these services, the service manager needs a high-level journal and links to all incidents that the customers raise.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 = [ ]; gr = new GlideRecord ( 'u_intensive_care' ); gr. query ( ); while (gr. next ( ) ) { arrUsers. push (gr. u_customer. toString ( ) ); } return arrUsers; } Related tasksCreate and edit filtersDelete filtersCreate a dynamic filter option On this page Send Feedback Previous Topic Next Topic
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. Before you beginRole required: admin Procedure Create a new script include. Navigate to System Definition > Script Includes. Click New. Fill out the form, and then select Submit. Open the script include and, in the Script field, create a JavaScript function that returns an array of sys_ids. Ensure that the function uses the same name as the script include. Ensure that the script include is Active and Client callable. Call the JavaScript function from the condition builder. For more information, see GlideRecord queries and Script includes. ExampleA company provides intensive care for a group of customers. To track these services, the service manager needs a high-level journal and links to all incidents that the customers raise.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 = [ ]; gr = new GlideRecord ( 'u_intensive_care' ); gr. query ( ); while (gr. next ( ) ) { arrUsers. push (gr. u_customer. toString ( ) ); } return arrUsers; } Related tasksCreate and edit filtersDelete filtersCreate a dynamic filter option
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. Before you beginRole required: admin Procedure Create a new script include. Navigate to System Definition > Script Includes. Click New. Fill out the form, and then select Submit. Open the script include and, in the Script field, create a JavaScript function that returns an array of sys_ids. Ensure that the function uses the same name as the script include. Ensure that the script include is Active and Client callable. Call the JavaScript function from the condition builder. For more information, see GlideRecord queries and Script includes. ExampleA company provides intensive care for a group of customers. To track these services, the service manager needs a high-level journal and links to all incidents that the customers raise.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 = [ ]; gr = new GlideRecord ( 'u_intensive_care' ); gr. query ( ); while (gr. next ( ) ) { arrUsers. push (gr. u_customer. toString ( ) ); } return arrUsers; } Related tasksCreate and edit filtersDelete filtersCreate a dynamic filter option