{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":197,"path":"api-reference/c_ScriptLoaderAPI.md","title":"ScriptLoader - Client","bundle":null,"doc_type":null,"release":"australia","body":"\n# ScriptLoader- Client\n\nThe ScriptLoader API provides methods to load scripts asynchronously.\n\nYou can use this API in client-side scripts for a platform/desktop UI using ListV2 and ListV3 APIs. It isn't available for Service Portal, Mobile, or Agent Workspace.\n\nYou access ScriptLoader methods by using the global object `ScriptLoader`.\n\n**Parent Topic:**[Client API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/api-client.md)\n\n## ScriptLoader - getScripts\\(Array scripts, Function callback\\)\n\nLoads scripts asynchronously.\n\n|Name|Type|Description|\n|----|----|-----------|\n|scripts|Array|Array of scripts to load.|\n|callback|Function|Function to call when the scripts have been loaded. The callback function must not have any arguments.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar scriptFiles=[\n'scripts/classes/providers/ProviderUI.js',\n'scripts/classes/providers/wf_provider_client_script.js'\n];\n\nScriptLoader.getScripts(scriptFiles, function() {\n  ProviderUI.setFields(['input_transform']);\n  ProviderUI.apply();\n  ProviderUI.removeDisabledAttribute(\"sys_readonly.wf_element_activity.access\");\n}\n```\n\n## ScriptLoader - getScripts\\(String filePath, Function callback\\)\n\nGets scripts asynchronously.\n\n|Name|Type|Description|\n|----|----|-----------|\n|filePath|String|Path, including the file name, that contains one or more scripts.|\n|callback|Function|Function to call after the scripts have been loaded. This callback function should not have arguments.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how load a utility script and then run the getDepartment\\(\\) function.\n\n```\n// Client script to load a utility script and run the getDepartment callback function\nScriptLoader.getScripts('sn_ui_script_util.Utilities.jsdbx', getDepartment);\n\nfunction getDepartment() {\n  var req = sn_ui_script_util.Utilities.rest('json');\n  req.addParam(\"sysparm_query\", \"sys_id=\" + newValue);\n  req.addParam(\"sysparm_fields\", \"department\");\n  req.addParam(\"sysparm_display_value\", true);\n  req.success(updateNotes);\n  req.get(\"/api/now/table/sys_user\");\n}\n\nfunction updateNotes(data) {\n  g_form.setValue(\"work_notes\", data.result[0].department.display_value);\n}\n```\n\n"}}