User ID not updating when other fields are getting updated correctly?

dalejaurigue11
Tera Expert

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:

find_real_file.png

find_real_file.png

Consumer email was updated but the Consumer User User ID is not getting updated
find_real_file.png

 

find_real_file.png

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

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();

 

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;
	}

find_real_file.png

find_real_file.png

Jaspal Singh
Mega Patron
Mega Patron

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);

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.