Why is state value not persisting with RESt API sn_chg_rest/change/standard request

Todd O
Tera Guru

I'm using out of the box REST API explorer to simply update a Standard Change record's "state" value from "New (-5)" to "Scheduled (-2)." When I submit the request I get a successful 200 OK response but the change does not happen on the CR. It's like it ignores it.  I've tried all the following approaches and none of them work. Any suggestions would be very much appreciated.

  1. I'm using this method: PATCH /sn_chg_rest/change/standard/{sys_id}
  2. I verified that my Standard change template does not have "state" as read-only. Here is the list of read-only fields when I run StdChangeUtils().getReadOnlyFields() method: "description,backout_plan,short_description,implementation_plan,test_plan,justification,category,business_service,parent"
  3. When specifying the parameter "state" in the payload, I've tried it as both a query parameter as well as JSON using the body. Neither work. There is a HI KB post that describes that you must use the Label (Scheduled) thus the reason I've tried both "Scheduled" as well as the -2 and "-2" values which is the value for Scheduled. Neither work - fact using the numbers gives an error just as the HI KB post discusses. 
  4. I've ensured that I also called the POST /conflict method as well to prove there is NO scheduling conflict with the CI. That doesn't solve it. 
  5. I've ensured that all required fields are populated with data values before attempting to change the state. That doesn't solve it either. 
  6. I've reviewed the business rules, workflows and Flow Designer objects to look for any running processes that would abort the attempted update and found nothing. 
  7. I've tried updating a different field (e.g., assigned_to and that works). But "state" does not work.

Finally, please see the images below showing the attempt and then results. Again, the question is why is it the state value does not get updated with this REST API call?

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

Did you check is there any dictionary override for state field on change_request table for read-only which is blocking the update from API?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@Ankur Bawiskar you have found it the root cause for me! See the side by side image below. The left side shows my instance where everything works as expected. The right side shows our QA image where I'm having this problem. Notice there is a dictionary override where the "Override read only" field is set to "true" in the instance where the problem exists. Also, I see there is a person's name in the "Updated by" column which tells me it was changed from out of the box. I updated this back to out of box "false" value and it's now working!!!

I need to better understand what this dictionary override read only field actually means. There must have been a reason this person changed it and I need to follow up with them. According to SN documentation it does the following: 

Select the check box to display the Read only field, which overrides whether a user can change the field value on the extended table.

Do you have some additional explanation on what this read-only set to true means? I'm still a bit fuzzy on it. I'm going to mark your answer as correct and thank you very much for your assistance!!!

find_real_file.png

 

 

Glad to help.

Since state field is on task table if you wish to extend some functionality such as default value, readonly etc you create dictionary override on the extended table

Define a dictionary override

Out of the box state field is editable on CHG table.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks again @Ankur Bawiskar! That makes sense and now I can see the behavior on the form that this setting either makes the field read only or not depending on whether it's checked.

Hi @Ankur Bawiskar , Can you please help me to get working curl for /sn_chg_rest/change/standard/{standard_change_template_id} API . I need to create a standard change request using a API

@Ankit Rastogi 

you can check the curl script when you use rest api explorer

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader