{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":35196,"path":"mobile/signature-input-writeback-action.md","title":"Configure a scripted writeback action that saves a signature input","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure a scripted writeback action that saves a signature input\n\nConfigure an action item's scripted writeback action that can save the signature input in your input form screen.\n\n## Before you begin\n\nYou must create an input form screen with signature inputs. For more information, see [Configure input form screens with signature inputs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/configure-signature-inputs.md).\n\nIn addition, you must have configured an action item to use for this input form screen. For more information, see [Configure an action item](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/sg-studio-create-action-item.md).\n\nRole required: admin\n\n## About this task\n\nAdmins can write scripts that perform the action and then save the signature inputs. Alternatively, they can write scripts that save the signature first before performing the action.\n\nYou can use the `MobileSignatureHandler` script include to save signature inputs. The `MobileSignatureHandler` script include saves the signature into the sys\\_attachment table and creates a relevant record in the signature\\_image table.\n\nYou can also write custom code to handle saving your signature inputs. For information about server-side scripting, see [Server-side scripting](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/scripts/c_ServerScripting.md).\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Mobile** &gt; **Action Items**.\n\n2.  Select the action item that you want to use for the signature input.\n\n3.  Add the signature saving script in the **Execution Script** field.\n\n    For example, the following writeback action item script shows how the `MobileSignatureHandler` can be used to save the signature input:\n\n    ```\n    (function WriteBackAction(parm_input, parm_variable, actionResult) {\n        var gr = new GlideRecord(\"incident\");\n        gr.get(parm_variable['sys_id']);\n        var shortDesc = parm_input['shortDescInput'];\n        gr.setValue(\"short_description\", shortDesc);\n        gr.update();\n          // in this example \"signatureInput\" is the name of a sys_sg_input of type signature\n          // SignatureType will return either \"Image\" or \"Text\"\n        var signatureType = parm_input['signatureInput'][\"SignatureType\"];\n          // SignatureValue will return a String containing the base64 respresentation of the image in the case of a drawn signature\n          // or a String with the name of the user if they typed their name\n        var signatureValue = parm_input['signatureInput'][\"SignatureValue\"];\n        var table = \"incident\";\n        var documentId = parm_variable['sys_id'];\n        var signatureHandler = new sn_mobile.MobileSignatureHandler();\n        if (signatureType == \"Image\")\n            signatureHandler.insertSignatureImage(table, documentId, signatureValue);\n        else if (signatureType == \"Text\")\n            signatureHandler.insertTypedSignature(table, documentId, signatureValue);\n    })(parm_input, parm_variable, actionResult);\n    ```\n\n4.  Select **Update** to save the configuration.\n\n\n"}}