The issue is resolved now. Following are the step-by-step process from creating a normal change request to moving the change request to closure.
As given in the below document make sure you uncheck the override read only and read-only fields for state field(field in change_reqest table) in servicenow.
and uncheck the read-only field for u_change_review field(field in change_reqest table) also.
Creation of change request:
Body:
{
"short_description" : "test_short_description",
"description" : "test_desc",
"start_date" : "2024-07-10 04:00:00", //"YYYY-MM-DD HH:mm:SS"
"end_date" : "2024-08-12 04:32:00", //"YYYY-MM-DD HH:mm:SS"
"assignment_group" : "test_assignment_group",
"cmdb_ci" : "test_cmdb_ci",
"reason" : "Business requirements",
"type" : "normal", //make sure you are giving normal instead of Normal
"u_change_owner" : "test_assignment_group",
"justification" : "test_justification",
"implementation_plan" : "test_implementation_plan",
"risk_impact_analysis" : "test_risk_impact_analysis",
"backout_plan" : "test_backout_plan",
"test_plan" : "test_plan",
"change_plan" : "test_change_plan",
"u_gxp_sensitive" : "no"
}
URL: https://<<dev.service-now.com>>/api/now/table/change_request
Method: Post
After creating change request, using rest API add affected CIs, create closure requirements and close the necessary change tasks.
Post that move the change request from new to assess
Body:
{
"state":"-4", // -4 - code for assess,
"work_note":"moving the state to assess"
}
URL: https://<<dev.service-now.com>>/api/now/table/change_request/<change_request_sys_id>
Method: Put
Now change request will be in Assess state.
post the necessary approval, change request will be moved to Authorize state.
Now we have to move the state to implement by following PUT requests.
1. updating the u_change_review to 'preReview' by passing following body
Body:
{
"work_note":"Implmented on Dev and QA ",
"u_change_review":"DevImplemented"
}
URL: https://<<dev.service-now.com>>/api/now/table/change_request/<change_request_sys_id>
Method: Put
2. now again update the u_change_review to 'postReview'
Body:
{
"work_note":"moving the state to Authorize",
"u_change_review":"postReview"
}
URL: https://<<dev.service-now.com>>/api/now/table/change_request/<change_request_sys_id>
Method: Put
Change request will be in implement state, now it has to be moved to Review state
Body:
{
"close_code":"successful",
"work_start":"2024-07-12 04:00:00",
"work_end":"2024-07-14 06:00:00",
"phase":"accept",
"state":"0" // code for review state
}
Now change request is in Review state, it will be moved to approval group by passing following body
Body:
{
"work_notes":"sending for approval in review state",
"u_change_review":"postReview"
}
URL: https://<<dev.service-now.com>>/api/now/table/change_request/<change_request_sys_id>
Method: Put
Now post the approval, it will be moved to Closed state
Note: Choice field values are dependant upon individual scenario.