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-28-2017 06:37 AM
Hi,
I have a onBefore Business rule to populate Name field on cmdb_ci_network_adapter.
The name field should be populated by "text123 MAC address" from the form.
ex: test123 00:00:00:00:00
function onBefore(current, previous /*null when async*/) {
var macAddress = current.cmdb_ci.mac_address;
var x = "abc";
current.name = x +'-'+macAddress;
}
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 06:48 AM
Do you have any condition or filter in BR. Also share the order and domain info of the BR. And is it on Insert or on update or on both.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 06:52 AM
I do not have any conditions.
Table : Network Adapter(cmdb_ci_network_adapter)
when : before
order 10000
On insert and on update
-thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 07:02 AM
I added mac address in the below mentioned ci record.
Then wrote a BR given below.
Script as below
(function executeRule(current, previous /*null when async*/) {
current.mac_address= 'abc'+' '+current.cmdb_ci.mac_address.toString();
})(current, previous);
Creating a new Network Adapter.
After inserting the value we have mac address as given below.
Hope this helps.
Regards
Ujjawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2017 07:24 AM
Thanks for the detail, appreciate it.
I got it working. I had to perform update on record to display the results.
Thanks everyone for your responses.
-thanks.