Populate value to a new field using BR in existing records

G_30
Tera Contributor

Hi Good day!

 

I would just like to ask how to use business rules in populating a value to a new field?

I already added a new dictionary entry/column in the xxx table.

 

and created a BR with the ff script.

current.xxx_column = current.assignment_group.getDisplayValue(),' to ', current.assigned_to.getDisplayValue();

 

This is just basically concatenating values from reference fields. I need to have the values even there is no update/newly inserted record in the xxx table.

 

Please advice. Thank you!

3 REPLIES 3

Mike_R
Kilo Patron
Kilo Patron

Your syntax should be updated

 

    current.xxx_column  = current.assignment_group.getDisplayValue() + " - " + current.assigned_to.getDisplayValue();

 

As far as updating all existing records, you'll need to create a fix script or flow to update the new field.

 

 

Example of a fix script would be

	var inc = new GlideRecord('incident');
	inc.addEncodedQuery('xxx_columnISEMPTY');//update xxx_column with your field name
	inc.query();
	while(inc.next()){
		inc.xxx_column  = inc.assignment_group.getDisplayValue() + " - " + inc.assigned_to.getDisplayValue();//update xxx_column with your field name
		inc.update();
	}

 

Obviously test in sub-prod first!

G_30
Tera Contributor

Thanks for this! it is actually worked but the action in BR is not what I am trying to work on, I just wanted to update the column thru backend, and no actions are needed from the user in order to populate the value because it causes lags/delay in the instance just to fill the column since there are a lot of incident already in our instance.