- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 05:17 AM
I am trying to recreate an exception like this java.sql.BatchUpdateException: Duplicate entry '0046b3f6bb927240f3611272dbdb75b8' for key 'PRIMARY' - I happened to find the solution for the same mentioned here: https://community.servicenow.com/thread/230668, but I would like to know what made this exception and I need to do to get an error message likewise.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 05:34 AM
In the exception you posted, the duplicate key is 'PRIMARY' which is a unique index on sys_id column (as this column is marked as PRIMARY KEY).
To reproduce this:
- have a before insert business where you use current.update()
that's the easiest way to reproduce probably.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 05:55 AM
For an example in sys_user table one user_name (yvette.kokoska) is already existing but still you are trying to insert one more user record with the same user_name, you will get the error.
You can try this in background script also..
var gr=new GlideRecord("sys_user");
gr.initilize();
gr.user_name="yvette.kokoska"; //replace with already existing user_name
gr.insert();
gs.info("Value is: "+gr.name);