- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:06 AM
Hi,
I have a requirement to create a business rule on the cmdb_ci_server table. So when a new record is created or updated with certain conditions, a records needs to be created in another table called FNMS Agent table. However, the name needs to have "FNMS Agent on" appended to the Name value in the FNMS table. I have created the below below business rule, is it ok? or is there a different way to concatenate strings in business rules?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:11 AM
Hello @snow_beginner ,
Yes the concatenation is correct as name field is string if the field is not a string then we can convert the field to string using .toString()
grFnms.name="FNMS Agent on "+current.name.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:14 AM
Hello snow_beginner,
I think your code will work, using '+' it's the easiest way to concatenate strings. In addition, instead using '=' for setting values I would use gr.setValue() function. Here's a short example:
grFnms.setValue('name', "FNMS Agent on "+current.name);
grFnms.setValue('host_name', current.name);
Using this, you can create a for structure for iterating and then store key values in arrays for having a cleaner and structured code. But as I have mentioned, your code should work 😃
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:11 AM
Hello @snow_beginner ,
Yes the concatenation is correct as name field is string if the field is not a string then we can convert the field to string using .toString()
grFnms.name="FNMS Agent on "+current.name.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:14 AM
Hello snow_beginner,
I think your code will work, using '+' it's the easiest way to concatenate strings. In addition, instead using '=' for setting values I would use gr.setValue() function. Here's a short example:
grFnms.setValue('name', "FNMS Agent on "+current.name);
grFnms.setValue('host_name', current.name);
Using this, you can create a for structure for iterating and then store key values in arrays for having a cleaner and structured code. But as I have mentioned, your code should work 😃
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 04:19 AM