{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":42448,"path":"platform-user-interface/service-portal/client-script-reference.md","title":"Supported client script types and APIs","bundle":null,"doc_type":null,"release":"australia","body":"\n# Supported client script types and APIs\n\nSome client scripts are not supported in Service Portal. Others must have a UI type set to **All** or **Mobile / Service Portal**. If using a client script in the Service Portal, only client-side APIs supported in a mobile environment can be used.\n\n## Client script support in Service Portal\n\n<table id=\"table_SPScriptSupport\"><thead><tr><th>\n\nClient script\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nCatalog client scripts\n\n</td><td>\n\nService Portal requires that the **UI Type** field be set to **All** or **Mobile / Service Portal**. Client Scripts marked as **Desktop** rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.\n\n</td></tr><tr><td>\n\nValidation scripts\n\n</td><td>\n\nService Portal requires that the **UI Type** field be set to **All** or **Mobile / Service Portal**. Client Scripts marked as **Desktop** rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.\n\n Validate user input in a specific field type using a validation script. In new instances, Service Portal includes XML, Script, Script \\(Plain\\), Email, and Version validation scripts by default. If upgrading from a previous release, the Mobile and Service Portal version is not active by default. You must activate the Mobile and Service Portal version of the validation script to validate user input in the Service Portal. See [Activate Service Portal validation scripts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/activate-sp-validation-scripts.md).\n\n **Note:** To call a UI script within a Validation script, use the g\\_ui\\_scripts global object. For more information, see GlideUIScripts. Verify that the UI script has the **Global** field set to false and **UI Type** set to Mobile / Service Portal or All.\n\n</td></tr><tr><td>\n\nUI scripts\n\n</td><td>\n\nService Portal requires that the **UI Type** field be set to **All** or **Mobile / Service Portal**. Client Scripts marked as **Desktop** rely on legacy APIs that are not supported in Service Portal. Before flagging a script as Mobile / Service Portal or All, make sure you are only using supported client-side APIs.\n\n</td></tr><tr><td>\n\nUI Actions\n\n</td><td>\n\nAll server-side UI actions are supported in Service Portal, although setRedirectURL\\(\\) operations are ignored because Service Portal forms handle redirection in a different way than the platform.\n\n The form widget ignores any UI Actions marked as **Client**.\n\n</td></tr><tr><td>\n\nUI Policies\n\n</td><td>\n\nSupported, although you should use only declarative UI Policies. Avoid scripting unless the outcome cannot be achieved through the condition builder.\n\n</td></tr><tr><td>\n\nUI Macros\n\n</td><td>\n\nNot supported as UI macros use Jelly.\n\n</td></tr><tr><td>\n\nFormatters\n\n</td><td>\n\nNot supported as formatters use Jelly.\n\n</td></tr></tbody>\n</table>## Supported client-side APIs\n\nSupported client scripting APIs for use in onLoad, onChange, and onSubmit client scripts.\n\nFor detailed class and method information, see the .\n\n<table id=\"table_skq_rjp_h1b\"><thead><tr><th>\n\nClass\n\n</th><th>\n\nAvailable methods\n\n</th></tr></thead><tbody><tr><td>\n\ng\\_form\n\n</td><td>\n\n-   addDecoration\\(fieldName, icon, title\\)\n-   addErrorMessage\\(message\\)\n-   addInfoMessage\\(message\\)\n-   addOption\\(fieldName, value, label, index\\)\n-   clearOptions\\(fieldName\\)\n-   getActionName\\(\\)\n-   getBooleanValue\\(fieldName\\)\n-   getDecimalValue\\(fieldName\\)\n-   getEncodedRecord\\(\\)\n-   getFieldNames\\(\\)\n-   getIntValue\\(fieldName\\)\n-   getLabel\\(fieldName\\)\n-   getReference\\(fieldName, callback\\)\n-   getRelatedListNames\\(\\)\n-   getSectionNames\\(\\)\n-   getSysId\\(\\)\n-   getTableName\\(\\)\n-   getValue\\(fieldName\\)\n-   hasField\\(fieldName\\)\n-   hideAllFieldMsgs\\(type: \"info \\| error\"\\)\n-   hideErrorBox\\(fieldName\\)\n-   hideFieldMsg\\(fieldName, clearAll\\)\n-   hideRelatedList\\(listTableName\\)\n-   hideRelatedLists\\(\\)\n-   isMandatory\\(fieldName\\)\n-   isNewRecord\\(\\)\n-   isReadOnly\\(fieldName\\)\n-   isVisible\\(fieldName\\)\n-   removeDecoration\\(fieldName, icon, title\\)\n-   removeOption\\(fieldName, value\\)\n-   save\\(\\)\n-   serialize\\(onlyDirtyFields\\)\n-   setFieldPlaceholder\\(fieldName, placeholder\\)\n-   setLabel\\(fieldName, label\\)\n-   setMandatory\\(fieldName, isMandatory\\)\n-   setReadOnly\\(fieldName, isReadOnly\\)\n-   setSectionDisplay\\(sectionName, isVisible\\)\n-   setValue\\(fieldName, value, displayValue\\)\n-   setVisible\\(fieldName, isVisible\\)\n-   showErrorBox\\(fieldName, message, scrollForm\\)\n-   showFieldMsg\\(fieldName, message, type: \"info \\| error\", scrollForm\\)\n-   showRelatedList\\(relatedTableName\\)\n-   showRelatedLists\\(\\)\n-   submit\\(submitActionName\\)\n\n **Note:** Using the `variables.var_name` notation with the g\\_form API is not supported in Service Portal. g\\_form as a global object cannot be used in a widget client controller or in a UI script.\n\n</td></tr><tr><td>\n\ng\\_list\n\n</td><td>\n\n-   get\\(fieldName\\)\n-   addItem\\(value, displayValue\\)\n-   removeItem\\(value\\)\n-   reset\\(\\)\n-   setQuery\\(queryString\\)\n-   setDefaultOperator\\(operator\\)\n-   getDefaultOperator\\(\\)\n\n</td></tr><tr><td>\n\ng\\_service\\_catalog\n\n</td><td>\n\nisOrderGuide\\(\\)\n\n</td></tr><tr><td>\n\nGlideAjax\n\n</td><td>\n\n-   addParam \\(name, value\\)\n-   getParam \\(name\\)\n-   getXML\\(callback\\)\n-   getXMLAnswer\\(callback\\)\n-   getJSON\\(callback\\)\n-   setErrorCallback\\(errorCallback\\)\n-   getURL\\(\\)\n-   getParams\\(\\)\n-   execute\\(\\)\n-   successCalback\\(data, status, xhr\\)\n-   errorCallback\\(xhr\\)\n-   setScope\\(scope\\)\n\n **Note:**\n\n-   Because the mobile platform does not allow synchronous GlideAjax calls, the getXMLWait\\(\\) method in a GlideAjax call does not work in the Service Portal. Instead, use one of the asynchronous calls such as getXML\\(Function callback\\) or getXMLAnswer\\(Function callback\\).\n-   GlideAjax cannot be used in a widget client controller.\n\n</td></tr><tr><td>\n\nGlideRecord\n\n</td><td>\n\n-   addQuery\\(encodedQuery\\)\n-   addQuery\\(fieldName, operator, value\\)\n-   getEncodedQuery\\(\\)\n-   get\\(id\\)\n-   getTableName\\(\\)\n-   hasNext\\(\\)\n-   insert\\(callback\\)\n-   gotoTop\\(\\)\n-   next\\(\\)\n-   loadRow\\(rowObj\\)\n-   getValue\\(fieldName\\)\n-   setValue\\(fieldName, value\\)\n-   isDotWalkField\\(fieldName\\)\n-   addOrderBy\\(fieldName\\)\n-   setDisplayFields\\(fieldNames\\)\n-   query\\(callback\\)\n-   setRows\\(rowsArray\\)\n-   setTableName\\(tableName\\)\n-   setLimit\\(maxInt\\)\n-   getLimit\\(\\)\n\n</td></tr><tr><td>\n\ni18NV3\n\n</td><td>\n\ngetMessage\\(String messageKey, Function callback\\)\n\n</td></tr></tbody>\n</table>**Parent Topic:**[Service Portal and client scripts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-user-interface/service-portal/unsupported_client_scripts.md)\n\n"}}