
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 12:32 AM
Hi,
I am trying to use record producer on sys_user table to update fields like email/dob etc. But the record producer that I have created is not updating properly. Instead its creating a new record. Used this 'current.setAbortAction(true)' but this is not working. Instead getting an error message -> Error: Unique Key violation detected by database ((conn=11872) Duplicate entry '844b673e87d29d50fea1ebd73cbb35fe' for key 'user_name')
Can someone help me on this? Attaching below script which I used on Script section of Record producer.
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('sys_id=' + current.user_id);
grUser.query();
if(grUser.next()){
grUser.email= producer.email;
grUser.u_date_of_birth = producer.u_date_of_birth;
grUser.u_date_of_joining = producer.u_date_of_joining;
grUser.update();
gs.addInfoMessage('User record updated successfully');
current.setAbortAction(true);
}
Thanks in Advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 03:26 AM
I found it myself, I made a mistake on the query. It is supposed to be producer.user_id and not current.user_id
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('sys_id=' + producer.user_id);
grUser.query();
if(grUser.next()){
grUser.email= producer.email;
grUser.u_date_of_birth = producer.u_date_of_birth;
grUser.u_date_of_joining = producer.u_date_of_joining;
grUser.update();
gs.addInfoMessage('User record updated successfully');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 02:09 AM
Correct, In User table it will start with u_, as it's a custom field.
Can you check in the record producer variable or variable set?
Regards,
Rahul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 03:26 AM
I found it myself, I made a mistake on the query. It is supposed to be producer.user_id and not current.user_id
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('sys_id=' + producer.user_id);
grUser.query();
if(grUser.next()){
grUser.email= producer.email;
grUser.u_date_of_birth = producer.u_date_of_birth;
grUser.u_date_of_joining = producer.u_date_of_joining;
grUser.update();
gs.addInfoMessage('User record updated successfully');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2024 08:20 PM
I used similar kind of script but i am gatting erorr in the record producer after submission., please help in this
var usrGR = new GlideRecord('incident');
usrGR.addQuery('sys_id', producer.incident);
usrGR.query();
if (usrGR.next()) {
usrGR.short_description = producer.comment;
usrGR.update();
}
gs.info(producer.comment);
current.setAbortAction(true);