
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 05:50 AM
Hi folks,
I have two list type fields on a form both are referenced from other tables.
I need to populate u_enterprise_app_definition.managed_by on to the Custom manged by field on change or update of Enterprise app definition field.
I have written the before business rule but dot walking is not working for list type fields. Can anyone give me the solution.
eg: current.u_custom_manged_by = current.u_enterprise_app_definition.managed_by; (but this is not working as the field type is list)
Thanks
Sumanth
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 07:46 AM
Code snippet you can try:
var managers = [];
if (!gs.nil(current.u_enterprise_app_definition)) {
var enterpriseAppDefinition = new GlideRecord('u_cmdb_ci_appl_enterprise');
enterpriseAppDefinition.addQuery('sys_id', 'IN', current.getValue('u_enterprise_app_definition'));
enterpriseAppDefinition.query();
while (enterpriseAppDefinition.next()) {
managers.push(enterpriseAppDefinition.getValue('managed_by'));
}
// Remove duplicates
var arrayUtil = new ArrayUtil();
managers = arrayUtil.unique(managers);
}
current.u_custom_manged_by = managers.join(',');
Just make sure you execute BR also when the value of Enterprise App Definition is empty.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 07:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 07:41 AM
You need to remove condition is not empty. As otherwise in case you clear the field, you want to clear also the second field. You can also improve the Business Rule that if the first field is empty, you will directly set the second field to empty value without doing GlideRecord query to improve performance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 07:46 AM
Code snippet you can try:
var managers = [];
if (!gs.nil(current.u_enterprise_app_definition)) {
var enterpriseAppDefinition = new GlideRecord('u_cmdb_ci_appl_enterprise');
enterpriseAppDefinition.addQuery('sys_id', 'IN', current.getValue('u_enterprise_app_definition'));
enterpriseAppDefinition.query();
while (enterpriseAppDefinition.next()) {
managers.push(enterpriseAppDefinition.getValue('managed_by'));
}
// Remove duplicates
var arrayUtil = new ArrayUtil();
managers = arrayUtil.unique(managers);
}
current.u_custom_manged_by = managers.join(',');
Just make sure you execute BR also when the value of Enterprise App Definition is empty.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2018 07:53 AM
Thanks a lot Dominic. It's working as expected.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2018 03:18 AM
Hi Dominik,
Further to the above query,I had one more requirement on the above. This is more about async.
If suppose when managed_by changes in the u_cmdb_appl_enterprise table , the same should update in u_custom_managed_by field on cmdb_ci_service table.
Can you please give me your inputs on this?
Thanks in advance.
Sumanth