{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":24433,"path":"intelligent-experiences/servicenow-lens/servicenow-lens-actions.md","title":"Define ServiceNow AI Lens behavior with Lens actions","bundle":null,"doc_type":null,"release":"australia","body":"\n# Define ServiceNow AI Lens behavior with Lens actions\n\nAs a Lens admin, you can create Lens actions in ServiceNow AI Lens to customize Lens behavior by providing default instructions, configuring context, and more.\n\nUse Lens actions to define default instructions, trigger options, custom context, and post processing instructions for the Lens response. With Lens actions, you can achieve the following goals:\n\n-   Trigger ServiceNow AI Lens from a desktop, ServiceNow instance, or Virtual Agent \\(from a mobile device or a portal\\)\n-   Auto-fill a form on the ServiceNow instance\n-   View the gathered insights in an editable preview\n-   Trigger flows, subflows, or actions after Lens execution\n-   Invoke AI agents\n-   Run ServiceNow AI Lens as a back-end service\n-   Auto-map the column headers of an Excel sheet with the columns of a ServiceNow table, and then insert the Excel sheet data into the ServiceNow table.\n\nWhenever ServiceNow AI Lens is launched from an instance, it checks if any active Lens action is available for the table. If available, it uses the logic defined in Lens action during execution. The Lens action can only be used by the users or groups or roles that are assigned to the Lens Actions record.\n\nRefer to the following examples to understand the different use cases of setting up the Lens actions.\n\n-   [Example: Scan documents to auto-fill the Insurance Request form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n-   [Example: Extract structured data from vendor agreements](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n-   [Example: Auto-fill user records on a user table](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n-   [Auto-map Excel sheet column headers with ServiceNow table columns](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n\n## Customize ServiceNow AI Lens behavior by creating a Lens action\n\nCreate a Lens action to define custom context, trigger options, and default instructions for the ServiceNow AI Lens execution.\n\n### Before you begin\n\nRole required: lens\\_admin\n\n### About this task\n\nLearn about the various Lens trigger options for ServiceNow AI Lens.\n\n<table id=\"table_ilf_l3c_yfc\"><thead><tr><th>\n\nGoal\n\n</th><th>\n\nTrigger From\n\n</th><th>\n\nTrigger For\n\n</th></tr></thead><tbody><tr><td>\n\nAuto-fill a form with a custom context and default instructions when triggered from the instance.When ServiceNow AI Lens is triggered from the instance in the context of the Lens action, the default instructions are always applied and specific form fields are extracted.\n\nTo view the procedure to define default instructions, see [Define default instructions for ServiceNow AI Lens](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/default-prompt-system-property-lens.md).\n\n</td><td>\n\nInstance\n\n</td><td>\n\nForm\n\n</td></tr><tr><td>\n\nAuto-fill a form with a custom context and default instructions when triggered from the ServiceNow AI Lens desktop app.You can trigger ServiceNow AI Lens from the desktop app directly in context of the Lens action instead of launching Lens from the instance. The default instructions are always applied and specific form fields are extracted.\n\n</td><td>\n\nDesktop\n\n</td><td>\n\nForm\n\n</td></tr><tr><td>\n\nAuto-map the column headers of an Excel sheet with the columns of a specified table, and then insert the Excel sheet data into the table.To view the procedure to auto-map the column headers of an Excel sheet with the columns of a table, and insert Excel data into the table, see [Auto-map Excel sheet column headers with table columns.](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n\n</td><td>\n\nDesktop\n\n</td><td>\n\nExcel Mapping\n\n</td></tr><tr><td>\n\nWith the help of a client script or server script, run ServiceNow AI Lens as a back-end service.\n\n</td><td>\n\nInstance\n\n</td><td>\n\nService\n\n</td></tr><tr><td>\n\nView the gathered insights in the preview window of ServiceNow AI Lens by providing custom context and perform post processing steps.\n\n</td><td>\n\nDesktop\n\n</td><td>\n\nOthers\n\n</td></tr></tbody>\n</table>When ServiceNow AI Lens is triggered from the instance or desktop to auto-fill a form, it uses an active Lens action associated with the target table.\n\nFor example, if a user selects **Create with Lens** from Incident table list, ServiceNow AI Lens checks for an active Lens action record for the Incident table where **Trigger From** is set to Instance and **Trigger For** is set to Form. If a matching action record exists, Lens executes in the context of that action.\n\n### Procedure\n\n1.  Navigate to **All** &gt; **ServiceNow AI Lens** &gt; **Lens Actions**.\n\n2.  Select **New**.\n\n3.  Enter a name and description for the Lens action in the Name and Description fields respectively.\n\n4.  In the **Trigger From** field, select one of the following options.\n\n    |Option|Description|\n    |------|-----------|\n    |**Desktop**|Option to specify that this action must be used when ServiceNow AI Lens is triggered from the ServiceNow AI Lens desktop app.|\n    |**Instance**|Option to specify that this action must be used when ServiceNow AI Lens is triggered from a ServiceNow instance.|\n\n5.  To save the changes, right-click the form header and select **Save**.\n\n6.  Set up the Lens action by filling the fields in the Lens Actions form, under the Customize heading.\n\n<table id=\"table_vjg_bbk_pfc\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nTrigger For\n\n</td><td>\n\n-   **Form** - Lens action is used when ServiceNow AI Lens is triggered to auto-fill a form. Apply a transformation logic to the Lens response before the form is auto-filled by using the [https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md) option.\n\nThis option is available when you select **Desktop** or **Instance** from the Trigger From list.\n\n-   **Service** - Lens action is used when ServiceNow AI Lens is used as a service. Select this option to trigger Lens from an instance to auto-populate a **Workspace form**, or to trigger it using Virtual Agent or Script Include.\n\nThis option is available when you select **Instance** from the Trigger From list.\n\n-   **Others** - Lens action is used when ServiceNow AI Lens is triggered to display a preview of extracted data and perform post processing steps, if applicable.\n\nThis option is available when you select **Desktop** from the Trigger From list.\n\n-   **Excel Mapping** -\n\nOption to specify that you can use this Lens action to attach an Excel sheet and let ServiceNow AI Lens auto-map its column headers with the columns of a table. After the auto-mapping is done, you can view and change the mapping, and insert the Excel sheet data to the table.\n\nThis option is available when you select **Desktop** from the Trigger From list.\n\n</td></tr><tr><td>\n\nOrder\n\n</td><td>\n\nExecution priority of the Lens action for a given table:-   **1**: Highest priority\n-   **999999**: Least priority\nThe default value is set to 100.\n\nFor example, if any user is assigned to two Lens action records for the same table, the Lens action with the least number is used during Lens execution.\n\n</td></tr><tr><td>\n\nTable\n\n</td><td>\n\nTable to which this Lens action applies. Selected table provides context during Lens execution when specific fields are selected or script is provided.For example, Incident table.\n\n</td></tr><tr><td>\n\nRequest Context\n\n</td><td>\n\nOption to provide enhanced context during Lens execution by selecting specific fields or providing custom schema via script.-   **Supported Fields** - Selected fields for providing enhanced context for Lens execution.\n-   **Advanced** - Script to generate a custom schema object for providing enhanced context for Lens execution.\n\n\n</td></tr><tr><td>\n\nFields\n\n</td><td>\n\nTable fields that you can select to provide enhanced context for Lens execution. Select fields to help Lens determine what information to extract from images. Only fields supported by Lens are available for selection. For more information, see [Field types supported](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/field-types-supported.md).This field appears only when **Supported Fields** is selected from the **Request Context** choice field.\n\n</td></tr><tr><td>\n\nPre Processing Script\n\n</td><td>\n\nScript to generate a custom schema object to provide enhanced context for Lens execution. Custom schema help Lens determine what information to extract from images.This field appears only when **Advanced** is selected from the **Request Context** choice field.\n\nExample sample script:\n\n```\nfunction preProcessRequest(lensActionRecord, inputJSON) {\n    // Initialize the schema object\n    var schemaObj = {};\n    /*\n    This is a utility method to generate schema object, \n    users can pass tableName and formFields as an array of fields for the given table to generate custom schema that is passed to the LLM.\n    \n    //Return schemaObj adhering to the structure defined in example\n    // tableName = 'incident'\n    tableName = inputJSON.tableName; \n\n    //formFields - array of fields for the given table.\n    //formFields = ['short_description', 'comments', 'impact'];\n    \n    fieldsToProcess = inputJSON.formFields;\n    schemaObj = new global.AILensSchemaUtil().generateSchema(tableName, fieldsToProcess);\n\n    */\n    return schemaObj;\n}\nvar schemaObj = preProcessRequest(lensActionRecord, inputJSON);\n```\n\nParameters accepted by the `preProcessRequest` method:\n\n-   **lensActionRecord** \\(Input\\) - GlideRecord of the Lens action that is executed.\n-   **inputJSON** \\(Input\\) - Optional JSON object that users can pass through service APIs.\n-   **schemaObj** \\(Output\\) - Returned JSON object of custom schema.\nExample of the returned schemaObj object:\n\n```\nschemaObj =  {\n  \"schemaPayload\": {\n    \"type\": \"json_schema\",\n    \"json_schema\": {\n      \"name\": \"schema_extraction\",\n      \"schema\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"short_description\": {\n            \"type\": \"string\",\n            \"label\": \"Short description\"\n          },\n          \"comments\": {\n            \"type\": \"string\",\n            \"label\": \"Additional comments\"\n          },\n          \"impact\": {\n            \"type\": \"choice\",\n            \"label\": \"Impact\",\n            \"choiceValues\": [\"1\", \"2\", \"3\"],\n            \"choiceLabels\": {\n              \"1 - High\": \"1\",\n              \"2 - Medium\": \"2\",\n              \"3 - Low\": \"3\"\n            }\n          }\n        },\n        \"required\": [\n          \"short_description\",\n          \"comments\",\n          \"impact\"\n        ],\n        \"additionalProperties\": false\n      }\n    }\n  },\n  \"fieldLabels\": [\"short_description\", \"comments\", \"impact\"]  //Optional key\n}\n```\n\n</td></tr><tr><td>\n\nDefault Additional Directions\n\n</td><td>\n\nDefault instructions that are supplied to AI in addition to the user-provided instructions.For example, `Summarize this paper by extracting the title, author name, publication date in the dd-mm-yyyy format, abstract, and keywords`\n\n</td></tr><tr><td id=\"transform-response\">\n\nTransform Response\n\n</td><td>\n\nOption to specify the transformation script for transforming the Lens response before auto-filling the form.This field appears only when **Form** is selected from the **Trigger For** choice field.\n\n</td></tr><tr><td>\n\nTransformation Script\n\n</td><td>\n\nScript that transforms the Lens response before populating the form.This field appears only when the **Transform Response** option is selected.\n\nSample script:\n\n```\nfunction transformResponseScript(lensActionRecord, lensResponse) {\n   // Initialize the schema object\n    var transformResponse = {};\n    \n    //Add your code here\n    \n    //Return schemaObj adhering to the structure defined in example\n    return transformResponse;\n}\nvar transformResponse = transformResponseScript(lensActionRecord, lensResponse);\n```\n\nParameters accepted by the `transformResponseScript` method:\n\n-   **lensActionRecord** \\(Input\\) - GlideRecord of the Lens action that is executed.\n-   **lensResponse** \\(Input\\) - JSON object of the Lens response provided after Lens execution.\n-   **transformResponse** \\(Output\\) - Returned JSON object of transformed schema.\nExample of the returned transformResponse object:\n\n```\ntransformResponse = {\n  \"short_description\": \"Service Degradation Error in Order Processing System\",\n  \"description\": \"The Order Processing API v2.1 encountered a service degradation issue in the Production environment\",\n  \"urgency\": \"1\"\n}\n```\n\n</td></tr><tr><td>\n\nEnable Post Processing\n\n</td><td>\n\nOption to specify advanced processing instructions after Lens execution is complete.This field appears only when **Others** or **Service** is selected from the **Trigger For** field.\n\n</td></tr><tr><td>\n\nPost Processing Script\n\n</td><td>\n\nScript that is run asynchronously after Lens execution to further process the Lens response, such as triggering a flow, subflow, actions, or AI Agent.This field appears only when the **Enable Post Processing** option is selected.\n\n```\nfunction postProcessResponse(lensActionRecord, lensResponse, lensExecutionRecord) {\n    \n    //Add your code here\n\n}\npostProcessResponse(lensActionRecord, lensResponse, lensExecutionRecord);\n```\n\nParameters accepted by the `postProcessResponse` method:\n\n-   **lensActionRecord** \\(Input\\) - GlideRecord of the Lens action that is executed.\n-   **lensResponse** \\(Input\\) - JSON object of the Lens response provided after Lens execution.\n-   **lensExecutionRecord** \\(Input\\) - GlideRecord of the Lens execution record.\n\n\n</td></tr><tr><td>\n\nWait for processed response\n\n</td><td>\n\nOption to wait for ServiceNow AI Lens to display the output of post-processing on the Preview window. If enabled, it waits for the post processing output. Else, it doesn't wait for post processing output but post processing continues in the background.\n\n</td></tr><tr><td>\n\nMax wait time \\(seconds\\)\n\n</td><td>\n\nThe maximum time ServiceNow AI Lens waits to display the output of post-processing. If the output doesn't appear within this duration, the session times out while the post-processing continues in the background until completion.\n\n</td></tr><tr><td>\n\nAttach Captured Images To Record\n\n</td><td>\n\nOption to attach the captured images to the record that is auto-filled using ServiceNow AI Lens.This option is enabled by default.\n\n</td></tr></tbody>\n</table>7.  To assign users or groups or rolesto the Lens action, under the Assigned Users and Groups or Roles heading, select **New**, and then use any one of the following methods.\n\n<table id=\"choicetable_hnt_fq4_13c\"><thead><tr><th align=\"left\" id=\"d70151e949\">\n\nMethod\n\n</th><th align=\"left\" id=\"d70151e952\">\n\nSteps\n\n</th></tr></thead><tbody><tr><td id=\"assign-roles-to-lens-action\">\n\n**Assign one or more roles to the Lens action**\n\n</td><td>\n\nSelect **Enable Roles** and perform the following steps.1.  Select the Unlock Roles \\(\\[Omitted image \"lens-lock-icon.png\"\\] Alt text: Roles Unlock icon.\\) icon.\n2.  Select the Look up icon \\[Omitted image \"lens-magnify-icon.png\"\\] Alt text: and then select a role.\n\nRepeat the step to add more roles.\n\n3.  Select the Lock Roles icon \\[Omitted image \"lens-lock-roles-icon.png\"\\] Alt text:.\n\n\n</td></tr><tr><td id=\"assign-users-to-lens-action\">\n\n**Assign one or more users to the Lens action**\n\n</td><td>\n\n1.  To assign yourself, select the Add Me icon \\[Omitted image \"lens-add-me-icon.png\"\\] Alt text:.\n2.  To assign one or more users, select the Unlock Users \\(\\[Omitted image \"lens-lock-icon.png\"\\] Alt text: Roles Lock icon.\\) icon.\n3.  Select the Look up icon \\[Omitted image \"lens-magnify-icon.png\"\\] Alt text: and then select a user.\n4.  Repeat the step to add more users.\n\n5.  Select the Lock Users icon \\[Omitted image \"lens-lock-roles-icon.png\"\\] Alt text:.\n\n\n</td></tr><tr><td id=\"assign-groups-to-lens-action\">\n\n**Assign one or more groups to the Lens action**\n\n</td><td>\n\n1.  Select the Unlock Groups \\[Omitted image \"lens-lock-icon.png\"\\] Alt text: icon.\n2.  Select the Look up icon \\[Omitted image \"lens-magnify-icon.png\"\\] Alt text: and then select a group.\n\nRepeat the step to add more groups.\n\n3.  Select the Lock Groups icon \\[Omitted image \"lens-lock-roles-icon.png\"\\] Alt text:.\n\n\n</td></tr></tbody>\n</table>    You can assign any one of the following combinations to the Lens action:\n\n    -   Assign roles to the Lens action.\n    -   Assign yourself and one or more groups to the Lens action.\n    -   Assign one or more users and groups to the Lens action\n8.  Select **Submit**.\n\n    The users or groups, or roles are assigned to the Lens action.\n\n    \\[Omitted image \"lens-action-form.png\"\\] Alt text: Users, groups, or roles assigned to Lens action\n\n9.  Select **Update**.\n\n10. Update the assignment of users or groups or roles to the Lens action.\n\n<table id=\"choicetable_ugv_m32_33c\"><thead><tr><th align=\"left\" id=\"d70151e1154\">\n\nAssignment type\n\n</th><th align=\"left\" id=\"d70151e1157\">\n\nSteps\n\n</th></tr></thead><tbody><tr><td id=\"d70151e1163\">\n\n**Roles**\n\n</td><td>\n\n1.  Under the heading **Assigned Users and Groups or Roles**, select the role.\n2.  To remove a role, select a role and then select \\(\\[Omitted image \"lens-file-attch-remove.png\"\\] Alt text: Remove role icon.\\)\n3.  Assign one or more new roles. For more information, see [https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n\n\n</td></tr><tr><td id=\"d70151e1197\">\n\n**Users**\n\n</td><td>\n\n1.  Under the heading Assigned Users and Groups or Roles, select the user.\n2.  To remove a user, select a user and then select \\(\\[Omitted image \"lens-file-attch-remove.png\"\\] Alt text: Remove role icon.\\)\n3.  Assign one or more new users. For more information, see [https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n\n\n</td></tr><tr><td id=\"d70151e1226\">\n\n**Groups**\n\n</td><td>\n\n1.  Under the heading Assigned Users and Groups or Roles, select the group.\n2.  To remove a group, select a group and then select \\(\\[Omitted image \"lens-file-attch-remove.png\"\\] Alt text: Remove role icon.\\)\n3.  Assign one or more new groups. For more information, see [https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md)\n\n\n</td></tr></tbody>\n</table>11. Select **Activate** for activating the Lens action.\n\n    The Lens action will be available on the ServiceNow AI Lens desktop application landing page.\n\n\n## Example: Scan documents to auto-fill the Insurance Request form\n\nEnable customers to scan documents related to car accident on their desktop to auto-fill the Insurance Request form on the ServiceNow instance.\n\n### Before you begin\n\nRole required: lens\\_admin\n\n### About this task\n\nYou can define in the Lens action that ServiceNow AI Lens must be triggered from the desktop to auto-fill the Insurance Request form. Lens action includes the fields that must be updated with the extracted data.\n\n\\[Omitted image \"lens-action-insurance-example.png\"\\] Alt text: Example Lens action record for auto-filling Insurance request form.\n\n### Procedure\n\n1.  Navigate to **All** &gt; **ServiceNow AI Lens** &gt; **Lens Actions**.\n\n2.  In the **Name** field, enter `Auto-fill Insurance Request from desktop`.\n\n3.  In the **Description** field, enter `Lens action for Boxeo Insurance to auto-fill the Insurance Request form when Lens is triggered from Desktop`.\n\n4.  From the **Trigger From** option, select Desktop.\n\n5.  In the form header, right-click and select **Save**.\n\n6.  From the **Trigger For** option, select Form.\n\n7.  In the **Table** field, select the Insurance Request table.\n\n8.  In the **Request Context** field, select Supported Fields to provide context.\n\n9.  From the **Fields** field, move fields to the Selected list.\n\n    `policy_number, location_of_incident, policy_holder_name, vehicle_number, policy_state, policy_checks_failed, policy_checks_passed, incident_date_time, damage_description, claim_type, claim_evaluation_percentage`\n\n10. In the **Default Additional Directions** field, enter the following directions for the AI.\n\n    ```\n    1. Incident Date : If available, extract the date from pictures uploaded.\n    2. Personal Information:\n    \t○ Names: Generate name from images or documents attached. If not present do not hallucinate.\n    3. Location:\n    \t○ If a vehicle number is visible, extract the corresponding city or state from images. If not found in images based on the vehicle number extract U.S city/state and use it as the location.\n    \t○ If no vehicle number is visible, leave the field blank.\n    4. Vehicle Number:\n    \t○ If present, use the visible vehicle number.\n    \t○ If not present, extract vehicle number from images like driving license. If not present, leave the field empty.\n    5. Policy Checks:\n    \t○ Refer to the policy checks document for validation.  \n    \t○ List only passed checks in policyChecksPassed as an HTML table with columns: Check Name, Status, Remarks.\n    \t○ List only failed checks in policyChecksFailed as an HTML table with columns: Check Name, Status, Remarks. If a document/image is not found for a check then add it to the policyChecksFailed.\n    \t○ No validation should be skipped. Consider all rules under each policy section and add them into policyChecksPassed or policyChecksFailed based on they status whether they are passed or failed.\n    6. Claim Evaluation:\n    \t○ Calculate the claimEvaluationPercentage using the formula:\n    (Number of Passed Checks / Total Number of Checks) * 100\n    7. Policy State:\n    \t○ \"Valid\" – if Claim Evaluation is 100,\n    \t○ \"Needs More Information\" – if Claim Evaluation is greater than 50 and less than 100,\n    \t○ \"Failed\" – if Claim Evaluation is less than or equal to 50.\n    8. Ensure the final output with all the above fields accurately filled.\n    ```\n\n11. Add users or groups who can use this Lens action.\n\n    1.  In the Assigned Users and Groups related list, select **New**.\n\n    2.  Select the required users or group of users that have the lens\\_user role.\n\n        Only the assigned users or group of users can leverage the Lens action during Lens execution.\n\n    3.  Select **Submit**.\n\n12. Select **Update**.\n\n13. Select **Activate** for activating the Lens action.\n\n\n## Example: Extract structured data from vendor agreements\n\nEnable compliance analysts to digitize and review several vendor agreements. Instead of manually entering details, they can launch ServiceNow AI Lens directly from the desktop, scan agreements, and adjust extracted values in the preview window before saving.\n\n### Before you begin\n\nRole required: lens\\_admin\n\n### About this task\n\nYou can define in the Lens action that ServiceNow AI Lens must be triggered from the desktop to scan the documents saved on the user system. With the post processing option, you can edit the extracted information in the preview window before saving and trigger post processing to create related list records.\n\n### Procedure\n\n1.  Navigate to **All** &gt; **ServiceNow AI Lens** &gt; **Lens Actions**.\n\n2.  In the **Name** field, enter `Extract data from vendor agreements`.\n\n3.  In the **Description** field, enter `Digitize and review several vendor agreements`.\n\n4.  From the **Trigger From** option, select Desktop.\n\n5.  In the form header, right-click and select **Save**.\n\n6.  From the **Trigger For** option, select Others.\n\n7.  In the **Request Context** field, select Advanced.\n\n8.  In the **Pre Processing Script** field, enter the script to generate custom schema object for providing enhanced context.\n\n    Here is the example of returned custom schema object:\n\n    ```\n    schemaObj =  {\n      \"schemaPayload\": {\n        \"type\": \"json_schema\",\n        \"json_schema\": {\n          \"name\": \"schema_extraction\",\n          \"schema\": {\n            \"type\": \"object\",\n            \"properties\": {\n              \"vendorName\": {\n                \"type\": \"string\",\n                \"label\": \"Vendor Name\"            \n              },\n              \"contractTitle\": {\n                \"type\": \"string\",\n                \"label\": \"Contract Title\"\n              },\n              \"contractReferenceNumber\": {\n                \"type\": \"string\",\n                \"label\": \"Contract Reference Number\"\n              },\n              \"contractStartDate\": {\n                \"type\": \"string\",            \n                \"label\": \"Contract Start Date\"\n              },\n              \"contractEndDate\": {\n                \"type\": \"string\",\n                \"label\": \"Contract End Date\"\n              },\n              \"renewalTerminationClauses\": {\n                \"type\": \"string\",\n                \"label\": \"Renewal / Termination Clauses\"\n              }\n            },\n            \"required\": [\n              \"vendorName\",\n              \"contractTitle\",\n              \"contractReferenceNumber\",\n              \"contractStartDate\",\n              \"contractEndDate\"\n            ],\n            \"additionalProperties\": false\n          }\n        }\n      },\n      \"fieldLabels\": [\"vendorName\", \"contractTitle\", \"contractReferenceNumber\", \"contractStartDate\", \"contractEndDate\"]  //Optional key\n    }\n    ```\n\n9.  In the **Default Additional Directions** field, enter directions for the AI, such as `Leave the fields empty if you don't find the relevant information. Don't hallucinate. Enter the date in the DD-MM-YYYY.`\n\n10. Select the **Enable Post Processing** option.\n\n11. In the **Post Processing Script** field, enter the script to provide the post processing logic for the Lens response after the Lens execution is complete.\n\n    You can provide a post processing logic to pass the data extracted to a subflow for creating related list records.\n\n12. Select the **Wait for processed response** field to enable the ServiceNow AI Lens to wait for ServiceNow AI Lens to display the output of post-processing on the Preview window.\n\n    If enabled, it waits for the post processing output. Else, it doesn't wait for post processing output but post processing continues in the background.\n\n13. In the **Max wait time \\(seconds\\)** field, specify the maximum time ServiceNow AI Lens waits to display the output of post-processing.\n\n    **Note:** If the output doesn't appear within that duration, the session times out while the post-processing continues in the background until completion.\n\n14. Add users or groups who can use this Lens action.\n\n    1.  In the Assigned Users and Groups related list, select **New**.\n\n    2.  Select the required users or group of users that have the lens\\_user role.\n\n        Only the assigned users or group of users can leverage the Lens action during Lens execution.\n\n    3.  Select **Submit**.\n\n15. Select **Update**.\n\n16. Select **Activate** for activating the Lens action.\n\n\n## Example: Auto-fill user records on a user table\n\nEnable service agents to create user records by extracting specific information from identity documents using ServiceNow AI Lens, directly from the ServiceNow instance.\n\n### Before you begin\n\nRole required: lens\\_admin\n\n### About this task\n\nA service agent must onboard multiple users by scanning their official ID cards \\(for example, government-issued ID\\). Instead of manually entering each user's details, the agents can trigger ServiceNow AI Lens from the instance to automate data extraction and auto-fill specific fields defined in the Lens action record.\n\nYou can define in the Lens action that ServiceNow AI Lens must be triggered from the instance to create user records and provide default directions.\n\n### Procedure\n\n1.  Navigate to **All** &gt; **ServiceNow AI Lens** &gt; **Lens Actions**.\n\n2.  Select **New**.\n\n3.  In the **Name** field, enter `Auto-fill the user records`.\n\n4.  In the **Description** field, enter `Lens action to auto-create the user records on the ServiceNow instance`.\n\n5.  From the **Trigger From** option, select Instance.\n\n6.  In the form header, right-click and select **Save**.\n\n7.  Confirm that the Form option is selected in the **Trigger For** field.\n\n    The Form option is selected by default.\n\n8.  In the **Table** field, select the User \\[sys\\_user\\] table.\n\n9.  Confirm that Supported Fields is selected in the **Request Context** field.\n\n    The Supported Fields value is selected by default, and it provides context.\n\n10. From the **Fields** field, move the fields to the Selected list.\n\n    `userID, first_name, last_name, title, and date_of_birth`\n\n11. In the **Default Additional Directions** field, enter `User ID must always be in lower case and uses the firstname.lastname format. Enter Date of birth in the dd-mm-yyyy format.`\n\n12. Add users or groups who can use this Lens action.\n\n    1.  In the Assigned Users and Groups related list, select **New**.\n\n    2.  Select the required users or group of users that have the lens\\_user role.\n\n        Only the assigned users or group of users can leverage the Lens action during Lens execution.\n\n    3.  Select **Submit**.\n\n13. Select **Update**.\n\n14. Select **Activate** for activating the Lens action.\n\n\n## Auto-map Excel sheet column headers with ServiceNow table columns\n\nUse ServiceNow AI Lens to map the column headers of an Excel sheet that you specify with ServiceNow® table columns and then insert the Excel sheet data into the table.\n\n### Before you begin\n\nRole required: lens\\_user\n\nEnsure that the Lens action for this purpose is already defined. To view the steps to define a Lens action, see [Define a Lens action](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/intelligent-experiences/servicenow-lens/servicenow-lens-actions.md). Ensure that the values in the Lens action form are exactly as specified in the following table.\n\n|Field|Option you must select|\n|-----|----------------------|\n|Trigger From|Desktop|\n|Trigger For|Excel Mapping|\n|Table|Name of the table with which the Lens action will auto-map the Excel sheet column headers.|\n|Request context|Supported Fields|\n|Fields|Columns of the table|\n\n**Tip:** A preconfigured Lens action that is designed to auto-map Excel sheet column headers with table columns is available by default on your instance. The name of the Lens action is `Import Excel Sheet data to custom table`. To use the Lens action, create a copy of this Lens action, and customize to create your own Lens action for this purpose.\n\n### Procedure\n\n1.  From your system, launch the ServiceNow AI Lens desktop application.\n\n2.  On the login page, in the **Instance URL** field, enter the ServiceNow instance URL.\n\n    For example, `https://<instance name>.service-now.com`.\n\n3.  Select **Proceed**.\n\n4.  Log in to your ServiceNow account by entering your username and password.\n\n5.  On the onboarding journey widget, complete the onboarding and select **Got it**.\n\n    \\[Omitted image \"onboarding-widget-lens.png\"\\] Alt text: Onboarding journey widget with three pages to show you the highlights of the application.\n\n    If you launch the ServiceNow AI Lens for the first time, the onboarding journey widget appears. You can select **Don't show me again** to hide the widget the next time you launch ServiceNow AI Lens.\n\n6.  Select the Lens action that you have defined for Excel mapping.\n\n    \\[Omitted image \"lens-sel-excel-map-action.png\"\\] Alt text: Excel mapping Lens action selected.\n\n    The **Proceed with Lens** button is disabled.\n\n    **Note:** The **Proceed with Lens** button is disabled because to auto-map Excel sheet column headers with the table columns, ServiceNow AI Lens requires you to only attach an Excel sheet.\n\n7.  Attach an Excel sheet by selecting **Upload** and then perform any one of the following file upload methods on the Upload file window.\n\n    \\[Omitted image \"lens-excel-mapping-file-upload-window.png\"\\] Alt text: Excel file upload window.\n\n<table id=\"choicetable_qnd_psb_13c\"><thead><tr><th align=\"left\" id=\"d70151e2334\">\n\nFile upload method\n\n</th><th align=\"left\" id=\"d70151e2337\">\n\nFile upload procedure\n\n</th></tr></thead><tbody><tr><td id=\"d70151e2343\">\n\n**Add file**\n\n</td><td>\n\n1.  Select **+Add file**,\n2.  Navigate to the location on your system and select the Excel sheet that you want to upload.\n\n**Note:**\n\n    -   You can upload only one Excel sheet.\n    -   **Tip:** To remove an Excel sheet that you attached, select the Remove file icon \\[Omitted image \"lens-file-attch-remove.png\"\\] Alt text:.\n\n    -   The data only in the first worksheet of the Excel sheet will be analyzed.\n\n\n</td></tr><tr><td id=\"d70151e2389\">\n\n**Drag and drop files**\n\n</td><td>\n\n1.  Navigate to the location on your system and select the Excel sheet that you want to upload.\n2.  Drag the selected Excel sheet to the Drag and drop section \\(\\[Omitted image \"lens-drag-and-drop.png\"\\] Alt text: Drag and drop section.\\), and release the pointer to drop them.\n\n**Note:**\n\n    -   You can drag and drop only one Excel sheet.\n    -   **Tip:** To remove an Excel sheet that you've attached, select the Remove file icon \\[Omitted image \"lens-file-attch-remove.png\"\\] Alt text:.\n\n    -   The data only in the first worksheet of the Excel sheet will be analyzed.\n\n\n</td></tr></tbody>\n</table>8.  Select **Next**.\n\n9.  Select **Analyze**.\n\n    \\[Omitted image \"lens-excel-map-analyze.png\"\\] Alt text: Analyze button.\n\n    ServiceNow AI Lens auto-maps the column headers of the attached Excel sheet and the table columns.\n\n    \\[Omitted image \"lens-excel-table-mapping.png\"\\] Alt text: Lens Excel and table column mapping.\n\n    **Tip:** You can change the mapping by selecting one or more different table columns under the Imported as field heading.\n\n10. Select **Submit**.\n\n    The Excel sheet data is inserted into the table.\n\n\n"}}