{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":5284,"path":"conversational-interfaces/virtual-agent/va-script-action.md","title":"Script Action utility","bundle":null,"doc_type":null,"release":"australia","body":"\n# Script Action utility\n\nUse the Script Action utility in a Virtual Agent topic to run a script.\n\n## Script Action utility properties\n\n<table id=\"table_nff_y1b_3db\"><thead><tr><th>\n\nProperty\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nNode name\n\n</td><td>\n\nThe name that identifies this Script Action node in the topic flow.\n\n</td></tr><tr><td>\n\nAction expression\n\n</td><td>\n\nThe script that performs an action.\n\n</td></tr><tr><td class=\"sub-head\" colspan=\"2\">\n\nAdvanced\n\n</td></tr><tr><td class=\"sub-head\" colspan=\"2\">\n\nHide this node\n\n</td></tr><tr><td>\n\nConditionally show this node if\n\n</td><td>\n\nNo-code condition statement or low-code script that specifies a condition for presenting this node in the conversation. The condition must evaluate to true.\n\n</td></tr></tbody>\n</table>## Example Script Action utility\n\n\\[Omitted image \"ScriptActionExample.png\"\\] Alt text: Basic properties include the node name and the action expression that contains the script.\n\n## Example script action\n\n```\n(function execute() {\n    var list = [];\n    if (vaInputs.case_number != \"\") {\n        var gr = new GlideRecord(\"sn_customerservice_case\");\n        gr.addQuery(\"number\", \"CONTAINS\", vaInputs.case_number);\n        gr.addQuery(\"active\", \"true\");\n        gr.orderBy(\"number\");\n        gr.query();\n        while (gr.hasNext()) {\n            gr.next();\n            list.push(gr.getUniqueValue().toString());\n        }\n    }\n    vaVars.case_list = list;\n})()\n\n```\n\nThis example performs a search on the \\[sn\\_customerservice\\_case\\] table for a specific case number based on the input from another control called `case_number`. The script then places the results in an array and stores them in the `case_list` variable, which is accessible by other nodes in the same topic. Because `vaVars` only supports string, number, and Boolean values, the script uses `toString()` to store these values as strings. The code is contained in an `if` statement, so it only executes if the `case_number` variable has a value. This `if` statement prevents the code from running if the user has not entered a number.\n\nFor more information about writing scripts for Virtual Agent, see [Virtual Agent scripts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/conversational-interfaces/virtual-agent/virtual-agent-scripts.md).\n\n**Parent Topic:**[Assistant Designer utilities](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/conversational-interfaces/virtual-agent/va-utilities.md)\n\n"}}