Update or close a ServiceNow change request

3 minute read

Use this functionality to update or close an existing ServiceNow change request. The user must provide:

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Inputs for the change request functionality are listed below.

Table 1. Input details
Change request model field Data type Required Description

url

String

Yes

The ServiceNow host URL.

username

String

Yes

The username used for authentication.

password

String

Yes

The password used for authentication.

client-id

String

Required only for OAuth-based authentication.

The unique identification number of the client.

client-secret

String

Required only for OAuth-based authentication.

The client secret used for authentication.

action-type

String

Yes

The type of operation must be "update" for both updating and closing a change request.

sys-id

String

Yes

The identifier auto-generated during change request creation.

close-code

String

Required for the close operation only if configured as mandatory fields in ServiceNow for closing a ticket.

The code assigned to the change request by the user closing it. For example, "successful", "successful with issues", or "unsuccessful".

close-notes

String

Required for the close operation only if configured as mandatory fields in ServiceNow for closing a ticket.

The notes entered by the user closing the change request.

short-description

String

No

A short title for easy identification.

description

String

No

Additional information about the change request ticket.

cr-type

String

No

The type of change request. The default value is "normal".

state

String

No

The current status of the change request (matches the ServiceNow configuration).

priority

String

No

The priority of the change request.

risk

String

No

The risk involved in the change request.

impact

String

No

The impact of the change request.

category

String

No

The change request ticket category.

requested-by

String

No

The user that requested the change.

assignment-group

String

No

The assignment group to which the change request must be mapped.

assigned-to

String

No

The user to whom the change request ticket must be assigned in the assignment group.

additional-parameters

JSON String

No

Any additional parameters apart from the list provided above. Refer to the ServiceNow documentation for more information.

Outputs

Outputs for the update change request functionality are listed below.

Table 2. Output details
Change request model field Data type Description

sys_id

String

The identifier used for change request updates.

state

String

The current status of the change request.

Usage examples: Update a change request

The following is an example payload for updating a change request using basic authentication:

- name: Update ServiceNow CR with basic auth uses: https://github.com/cloudbees-io/service-now@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ secrets.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} action-type: "update" sys-id: "the unique system-generated string" description: "Updated description from CBP workflow" priority: "3 - Moderate" risk: "Low" additional-parameters : '{"risk_impact_analysis":"Describe the risks here","implementation_plan": "Describe the implementation plan here"}'

The following is an example payload referring to the output parameter sys_id from the change request creation step as input in the update step:

- name: Update ServiceNow CR with output parameter ref uses: https://github.com/cloudbees-io/service-now@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ secrets.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} action-type: "update" sys-id: ${{ fromJSON(steps.create_cr.outputs.servicenow_output).sys_id }} description: "Updated description from CBP workflow" priority: "3 - Moderate" risk: "Low" additional-parameters : '{"risk_impact_analysis":"Describe the risks here","implementation_plan": "Describe the implementation plan here"}'

Usage examples: Close a change request

The following is an example payload for closing a change request:

- name: Close ServiceNow CR with mandatory close fields uses: https://github.com/cloudbees-io/service-now@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ vars.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} client-id: ${{ secrets.MY_CLIENT_ID }} client-secret: ${{ secrets.MY_CLIENT_SECRET }} action-type: "update" sys-id: "Unique ServiceNow-generated identifier" state: "close" close-code: "successful" close-notes: "Change request closed in successful state"

The following is an example payload referring to the output parameter sys_id from the change request creation step as input in the close step:

- name: Close ServiceNow CR with output parameter ref uses: https://github.com/cloudbees-io/service-now@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ secrets.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} client-id: ${{ secrets.MY_CLIENT_ID }} client-secret: ${{ secrets.MY_CLIENT_SECRET }} action-type: "update" sys-id: ${{ fromJSON(steps.create_cr.outputs.servicenow_output).sys_id }} state: "close" close-code: "successful" close-notes: "Change request closed in successful state"

For information about using input parameters in a manually triggered workflow, refer to the Create change request usage example.