How do i concatenate address using business rule.

Alok21
Giga Expert

Hi Team,

I have a requirement to concatenate few fields into a string field and i am not sure how i can achieve this.

The address field should be concatenated as below.

DEUTSCHE BANK
Technik Niederlassung West
Field Operations Mobile (T-MRF)
Detmolder Str. 380
33605 Bielefeld
Germany  

Can someone please assist on this?

Regards,

Alok sahu

 

 

1 ACCEPTED SOLUTION

Hi Ankur,

The issue has been fixed. I just increased the max length of the field to 300 and it worked 🙂

Regards,

Alok sahu

 

View solution in original post

8 REPLIES 8

AbhishekGardade
Giga Sage

Hello Alok,

you can simply use:

ar str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);

OR:

Replace with your field name:

current.u_field_four = current.u_field_one + ', ' + current.u_field_two;

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Alok,

use below script and it should concatenate; have this in before insert/update business rule

do you want hardcoded value in the field or based on some fields of the table; modify code as per that

current.<fieldName> = current.<field1> + " " + current.<field2> + " " + current.<field3>;

do you want to have new line character or in single line?

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I have done as per below but it is concatenating in single line. 

current.<fieldName> = current.<field1> + " " + current.<field2> + " " + current.<field3>;

I want it in new line as below. 

DEUTSCHE BANK
Technik Niederlassung West
Field Operations Mobile (T-MRF)
Detmolder Str. 380
33605 Bielefeld
Germany  

Regards,

Alok sahu

Hi Alok,

Is that field a string field?

because string field has this behaviour

For 255 characters or less, the string field is a single-line text field. Anything 256 characters or over appears as a multi-line text box.

update code as below; and it will add new line but it will only show in new line if total char crosses 256

current.<fieldName> = current.<field1> + "\n" + current.<field2> + "\n" + current.<field3>;

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader