Populate display name field using business rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 10:37 PM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 11:09 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 05:37 AM
Both fields are Type: string, I was unable to get the script working.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 06:08 AM
Set Order of BR as 100000 and then try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2017 11:12 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 06:22 AM
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.