{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":25760,"path":"it-asset-management/saas-license-management/create-data-stream-remove-user.md","title":"Create an action to remove a user","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create an action to remove a user\n\nCreate an action to deactivate or delete a user account in the SaaS application.\n\n## Before you begin\n\nIf you're using an existing ServiceNow® Integration Hub spoke, find out if it has an action to remove a user that you can use instead of creating one.\n\nRole required: flow\\_designer\n\n## About this task\n\nThis action is used to reclaim unused subscriptions to reduce your company's software expenses.\n\n## Procedure\n\n1.  Navigate to **All** &gt; **Flow Designer** &gt; **Designer**.\n\n2.  Click **New** and then select **Action**.\n\n3.  On the form, fill in the fields.\n\n    |Field|Value|\n    |-----|-----|\n    |Name|Name of your choice. For example, **Remove User**.|\n    |Accessible From|**All application scopes**.|\n    |Category|Leave this field empty.|\n    |Protection|**None**.|\n    |Application|Spoke app to integrate with the SaaS application. This can be an existing Integration Hub spoke or a new spoke that you created.|\n    |In-Flow Annotation|Leave this field empty.|\n    |Description|Description of your choice.|\n\n4.  Click **Submit**.\n\n5.  In the Inputs section of the Action Outline, click **Create Input**.\n\n6.  Add a user ID input.\n\n    This is how the action gets the user ID of the user to delete.\n\n    |Label|Name|Type|Mandatory|\n    |-----|----|----|---------|\n    |User ID|userID|String|Yes|\n\n7.  If the API that you're working with requires user authentication for requests, add inputs for authentication.\n\n    Examples of common user authentication inputs are admin user id and site name. See the documentation for your chosen API to learn about the requirements for user authentication in your specific case. If the API requires an access token, a *Credential Value* variable is automatically created later so you don't need to add it as an input.\n\n    When you use your completed action in a subflow, you define what values to pass as these inputs.\n\n8.  Add a **SOAP step** or **REST step** to the action outline.\n\n    Your choice will depend on the API for the SaaS application that you're integrating with.\n\n9.  If you selected **SOAP**, fill in the form as shown.\n\n<table id=\"table_o2c_w4j_rjb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nValue\n\n</th></tr></thead><tbody><tr><td colspan=\"2\">\n\nConnection Details\n\n</td></tr><tr><td>\n\nConnection\n\n</td><td>\n\n**Use Connection Alias**.\n\n</td></tr><tr><td>\n\nConnection Alias\n\n</td><td>\n\nConnection alias that you created when you created the integration profile. If you have not yet created an integration profile, follow the steps to [create a custom integration profile with a connection alias.](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-asset-management/saas-license-management/create-integration-custom.md)\n\n</td></tr><tr><td>\n\nEndpoint\n\n</td><td>\n\nThis value is automatically populated when you select the connection alias. It's set to the Connection URL from the HTTP\\(s\\) Connection record linked to the alias.\n\n</td></tr><tr><td colspan=\"2\">\n\nRequest Details\n\n</td></tr><tr><td>\n\nBuild Envelope\n\n</td><td>\n\n**Manually**.\n\n</td></tr><tr><td>\n\nSOAP Action\n\n</td><td>\n\nAPI request to delete or deactivate a user. See the documentation for your chosen API to select the appropriate request.\n\n</td></tr><tr><td>\n\nSOAP Envelope\n\n</td><td>\n\nXML request message to delete a user. See the documentation for your chosen API to learn how to write an XML request message. In general, the header should have your input variables for user authentication as well as the *Credential Value* variable as the access token. The body should include the request to delete a user and the user ID input. **Note:** For an example of a SOAP envelope, see the Remove User action used in the Webex Reclaim Subscription subflow.\n\n</td></tr></tbody>\n</table>10. If you selected **REST,** fill in the form as shown.\n\n    |Field|Value|\n    |-----|-----|\n    |Connection Details|\n    |Connection|**Use Connection Alias**.|\n    |Connection Alias|Connection alias that you created when you created the integration profile. If you have not yet created an integration profile, follow the steps to [create a custom integration profile with a connection alias.](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-asset-management/saas-license-management/create-integration-custom.md)|\n    |Base URL|This value is automatically populated when you select the connection alias. It's set to the Connection URL from the HTTP\\(s\\) Connection record linked to the alias.|\n    |Request Details|\n    |Build Request|**Manually**.|\n    |Resource Path|Path to the resource. This value gets appended to the Base URL. See the documentation for the API that you're working with to learn how to construct the resource path.|\n    |HTTP Method|**DELETE**.|\n    |Query Parameters|Add a parameter for user ID. Set the value as the user ID input.|\n\n11. Add a **Script step** to the Action Outline for error handling.\n\n    1.  For **Required Runtime**, select **Instance**.\n\n    2.  Create input variables.\n\n        |Name|Value|\n        |----|-----|\n        |response|Response Body output from the SOAP or REST step|\n        |status\\_code|Status Code output from the SOAP or REST step|\n\n    3.  Create output variables.\n\n        |Label|Name|Type|Mandatory|\n        |-----|----|----|---------|\n        |status|status|Choice|Yes|\n        |error\\_message|error\\_message|String|Yes|\n\n    4.  In the **Script** field, write a script to assign values to the status and error message outputs.\n\n        -   Use the **status\\_code** input to check if there is an error. Set the status output equal to **Error** if there is an error and **Success** if there is no error.\n        -   In cases where there is an error, use the **response** input to get information about the kind of error. Set the **error message** output to a description of the error so that a user can understand what went wrong.\n12. In the Action Outline, click **Outputs**.\n\n13. Create output variables.\n\n    |Label|Name|Type|Mandatory|\n    |-----|----|----|---------|\n    |Status|status|Choice|No|\n    |Error message|error\\_message|String|No|\n\n14. Assign values to the output variables.\n\n    |Label|Value|\n    |-----|-----|\n    |Status|**status** output variable from the script step|\n    |Error message|**error\\_message** output variable from the script step|\n\n15. To test your action, click **Test**.\n\n    1.  View the test results and system logs for details about any errors.\n\n        To view system logs, navigate to **System Logs** &gt; **System Log** &gt; **All**.\n\n    2.  If your action has errors, make sure that you're using the correct endpoints and that the API request is structured as expected.\n\n    **Note:** When testing, remember that this action deactivates a user. Test this action in a sub-production environment. If only a production environment is available, you can create fake users for testing.\n\n16. After verifying that the action is working as expected, click **Publish**.\n\n\n"}}