The CreatorCon Call for Content is officially open! Get started here.

Populate display name field using business rules

Bargavi
Mega Expert

Hi,

I am trying to populate field_1 with the value "abc field_2" using business rule.

I have tried couple of Before business rule scripts, none of them are working

1. used concatenation

var field_2 = current.u_field_2;

var x = "abc";

var sum = x +' '+field_2;

current.field_1= sum;

2.

(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord(table_name);
gr.query();

var field_2 = current.u_field_2;
while(gr.next())
{

current.field_1= 'abc' + current.field_2 + ' ';

}
})(current, previous);

can anyone point me in right direction, please.

-Thanks

14 REPLIES 14

Ujjawal Vishnoi
Mega Sage

Hi Bargavi,



If field_1 and field_2 are not a reference field. Please try below code.



current.field_1= 'abc'+' '+current.u_field_2.toString();



Hope this helps.



Regards,


Ujjawal


Both fields are Type: string, I was unable to get the script working.



-Thanks


Set Order of BR as 100000 and then try.


lSurya 24
Giga Guru

Hello Bargavi,



The first approch you used seems to be correct. just check the field names which you are using in the BR.



var field_2 = current.u_field_2;


var x = "abc";


var sum = x +'   '+field_2;


current.field_1= sum; // may be the field name would be u_field_1



Thanks,


Surya Amara




PS: Hit like, Helpful or Correct depending on the impact of the response


Patrick Schult2
Giga Guru

Can you show us the entire business rule? You're saying you can't get anything to work, which is a symptom that your business rule isn't running at the right time or at all.