Create an action to remove a user
- UpdatedAug 3, 2023
- 4 minutes to read
- Vancouver
- IT Asset Management
The Vancouver release is no longer supported. As such, the product documentation and release notes are provided for informational purposes only, and will not be updated.
Create an action to deactivate or delete a user account in the SaaS application.
Before you begin
If 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.
Role required: flow_designer or admin
About this task
This action is used to reclaim unused subscriptions to reduce your company's software expenses.
Procedure
- Navigate to All > Flow Designer > Designer.
- Click New and then select Action.
-
On the form, fill in the fields.
Table 1. Action Properties form Field Value Name Name of your choice. For example, Remove User. Accessible From All application scopes. Category Leave this field empty. Protection None. Application Spoke app to integrate with the SaaS application. This can be an existing Integration Hub spoke or a new spoke that you created. In-Flow Annotation Leave this field empty. Description Description of your choice. - Click Submit.
- In the Inputs section of the Action Outline, click Create Input.
-
Add a user ID input.
This is how the action gets the user ID of the user to delete.
Table 2. Inputs Label Name Type Mandatory User ID userID String Yes -
If the API that you're working with requires user authentication for requests,
add inputs for authentication.
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.
When you use your completed action in a subflow, you define what values to pass as these inputs.
-
Add a SOAP step or REST step to the action outline.
Your choice will depend on the API for the SaaS application that you're integrating with.
-
If you selected SOAP, fill in the form as shown.
Table 3. SOAP step form Field Value Connection Details Connection Use Connection Alias. 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. Endpoint 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. Request Details Build Envelope Manually. SOAP Action API request to delete or deactivate a user. See the documentation for your chosen API to select the appropriate request. SOAP Envelope XML 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. -
If you selected REST, fill in the form as shown.
Table 4. REST step form Field Value Connection Details Connection Use Connection Alias. 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. 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. Request Details Build Request Manually. 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. HTTP Method DELETE. Query Parameters Add a parameter for user ID. Set the value as the user ID input. -
Add a Script step to the Action Outline for error
handling.
- For Required Runtime, select Instance.
-
Create input variables.
Table 5. Input Variables Name Value response Response Body output from the SOAP or REST step status_code Status Code output from the SOAP or REST step -
Create output variables.
Table 6. Output Variables Label Name Type Mandatory status status Choice Yes error_message error_message String Yes -
In the Script field, write a script to assign
values to the status and error message outputs.
- 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.
- 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.
- In the Action Outline, click Outputs.
-
Create output variables.
Table 7. Output Variables Label Name Type Mandatory Status status Choice No Error message error_message String No -
Assign values to the output variables.
Table 8. Output Variables Label Value Status status output variable from the script step Error message error_message output variable from the script step -
To test your action, click Test.
-
View the test results and system logs for details about any
errors.
To view system logs, navigate to System Logs > System Log > All.
- If your action has errors, make sure that you're using the correct endpoints and that the API request is structured as expected.
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. -
View the test results and system logs for details about any
errors.
- After verifying that the action is working as expected, click Publish.