duplicate incident number created automatically when I update the servicenow incident

SN_2023
Tera Contributor

Hi,

 

issue: Servicenow Incident/TASKS

My OS : Windows 10 64 bit

Excel   : VBA 2019 64 bit

REST API

Browser: Bravo

 

When I update the fields of the Incident, say for example number INC0010001, it did not get update but some other incident changed to this number and updated. The incident INC0010001 was also there. I see 2 incidents with same number. looking Strange.

 

number                state     short_desc   desc

INC0010001         4        xxxxxx           yyyyy

INC0020011         3        aaaaaa           ssssss

INC0030021         3        bbbbbb          fffffff

INC0040031         3        zzzzzz            rrrrrrr

 

If I update the record INC0040031 as INC0040031, "kkkkk", "mmmmm", some other Incident changed to this number and get updated. But the actual Incident is not getting changed. There are 2 incidents with same Incident number.

The result would looked like this:

 

number                state     short_desc   desc

INC0010001         4        xxxxxx           yyyyy

INC0020011         3        aaaaaa           ssssss

INC0040031         3        kkkkk             mmmmm

INC0040031         3        zzzzzz            rrrrrrr

 

Please note the last 2 records. INC0030021 changed to INC0040031 and get updated but not the 

actual required record get updated. But it is also there.

 

I am updating from EXCEL VBA 2019 using REST API through "put" command. I see the same behavior when updating the incident through Servicenow REST API page.

 

Same result for TASKS also.

 

Note: If I use "patch" command in Excel VBA, I received the error as like this "This feature is not allowed". 

I used patch command in Servicenow REST API page.

 

Can you recommend any solutions to resolve the issue?

 

thank you.

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @SN_2023 ,

 

The behavior you are describing seems to be related to a potential conflict or issue with how the ServiceNow instance is handling updates through the REST API. Here are a few recommendations and potential solutions to resolve the problem:

 

### 1. **Ensure Unique Incident Numbers:**

   - Make sure that incident numbers (`INCXXXXXXX`) are unique in the ServiceNow instance. Duplicate incident numbers can cause confusion and unexpected behavior. If there are multiple incidents with the same number, it can lead to updates being applied to unintended records.

 

### 2. **Check Business Rules and Scripts:**

   - Review any active Business Rules, UI Policies, or Client Scripts in your ServiceNow instance. These configurations might be interfering with the update operations. Check if there are any scripts that are changing incident numbers or redirecting updates to different records.

 

### 3. **Check REST API Endpoint:**

   - Verify that you are sending the PUT request to the correct REST API endpoint. Double-check the URL you are using in your Excel VBA code. Ensure it points to the correct table and record you intend to update.

 

### 4. **Review REST API Request Payload:**

   - Check the payload you are sending in your PUT request. Ensure it includes the correct incident number (`number` field) and the updated values for `state`, `short_desc`, and `desc`. Validate the payload structure to make sure it matches the ServiceNow table schema.

 

### 5. **Test with Different REST Clients:**

   - Test the same update operation using different REST clients like Postman or cURL. This can help isolate the issue to Excel VBA or the ServiceNow instance. If the problem persists across different clients, it might be an issue with ServiceNow configurations.

 

### 6. **ServiceNow Support:**

   - If none of the above solutions work, it's advisable to contact ServiceNow support. Provide them with detailed information about the issue, including the steps to reproduce, payload samples, and any error messages you receive. They can analyze the configurations in your specific instance and provide targeted assistance.

 

### 7. **Excel VBA PATCH Command:**

   - If you are receiving an error when using the PATCH command in Excel VBA, consider investigating the cause of this error. Check if there are any Excel or network security settings preventing the use of the PATCH method. You might need to adjust security settings or consult with your IT support for assistance.

 

By following these steps and thoroughly investigating the potential causes, you should be able to identify and resolve the issue with updating incidents in ServiceNow through the REST API.

 

Mark my answer helpful & accepted if it helps you resolve your query.

 

Thanks,

Danish

SN_2023
Tera Contributor

Hi Danish,

 

Thanks for your response to my question. I thought the sys_id is same for GET operation. The Incident Number is the Primary Key. So I have to supply Incident Number to update the required fields. But only later I understood that each incident has unique sys_id. If we want to update the record we must send the sys_id of the record to be updated along with other necessary fields to be updated. It is not necessary to send Incident Number. I am working on the issue.

 

let you know the result. If my understanding is wrong, please enlighten me regarding this issue.

 

Thank you.

Danish Bhairag2
Tera Sage
Tera Sage

Hi @SN_2023 ,

 

You are absolutely correct each record has a unique ID called as Sys ID. It would be best if u r able to get & update the record using the sys id.

 

Thanks,

Danish