Automaticly copy value of one field to another field on same table

Igor Baldi
Tera Contributor

Hello, I want to know how to copy value from one field to another. It should be automatic for every other entry.

"customer_contact" table, it should copy value from field “email” to “user_name”.

I tried to create BR, but it did not work.

Any suggestions?

1 ACCEPTED SOLUTION

Saiganeshraja
Kilo Sage

In business, rules use actions to set the value. (If both are of the same type) as email and user id fields are the different types we need set from the script :

When to run: before (insert,update)

current.user_id = current.email.toString();

 

 

Mark correct and helpful.

View solution in original post

8 REPLIES 8

Sorry I did misspell field. Now it works like a charm!

Is it correct 

var val=g_form.getValue('u_short_description');
var array_val=val.split('\n');
g_form.setValue('u_description',array_val[0]);

Community Alums
Not applicable

If the user ID is an email address, you could have also done:
current.user_id.getDisplayValue() = current.email;

Thanks for replying and 

 for this code am not getting count ,could you please help where have to modified ,am getting number , in count undefined
var ga = new GlideAggregate('incident'); // COUNT ,SUM MIN MAX AVG
ga.addQuery('category','software');
//ga.setGroup(false);
//ga.setCategory(); //set the value of category query
//ga.addAggregate('COUNT','sys_mod_count');
ga.query();
while(ga.next())
{
gs.info(ga.number);
gs.info('COUNT :' + ga.addAggregate('COUNT','sys_mod_count') );
}