User ID not updating when other fields are getting updated correctly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 03:35 AM
Hi SN Community, I have an issue regarding User ID(user_name) field value not updating when other fields are getting updated correclty.
Here is the BR script that is responsible for creating/updating the record:
Consumer email was updated but the Consumer User User ID is not getting updated
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 04:16 AM
The Email field on the sys_user table has the type of 'Email' which means it is not the same as a String field. To populate the contents of an email type field into a string type field, force it to the string format like so:
ConsumerUserTableGr.user_name = current.email.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 06:14 AM
Hi Brad, I tried doing what you suggested and it still is not updating the User ID (user_name) field.
var ConsumerUserTableGr = new GlideRecord("csm_consumer_user");
ConsumerUserTableGr.initialize();
if(gs.nil(current.getValue('user'))){
ConsumerUserTableGr.first_name = current.first_name;
ConsumerUserTableGr.last_name = current.last_name;
ConsumerUserTableGr.email = current.email;
ConsumerUserTableGr.user_name = current.email.toString();
var user = ConsumerUserTableGr.insert();
current.user = user;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 06:27 AM
Bit confused. You have 3 screenshots.
First is fine.
Second one one does not have the user_name field itself.
Third one has value.
So, if I understand it is the Third image that you have manually populated value with. Kindly confirm if this is not the case. Also, what table Business Rule is on?
Also, try below for a check
ConsumerUserTableGr.user_name.setDisplayValue(current.email);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2022 07:13 AM
Hi Jaspal, So the second screenshot is of the Consumer record on the Consumer table, I tried changing the email from this table manually to check if the changes would reflect to the Consumer User table which extends the sys_user table. First name, last name, and email updated fine except for the User ID which should be the same with email.
The business rule is on Consumer table(csm_consumer).
I tried the code you suggested and it still wont update the User ID (user_name) field on Consumer User table.