Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:02 PM - edited 09-01-2023 05:44 PM
Hi Team i have a field that is from CMDB Integration and when i try to call him in business rule it doesn't work does anyone know why ?
if (current.name_of_field === 'Active')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:15 PM - edited 09-01-2023 05:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:33 PM
Uhh... that would only work if the x_snsab_snow_sam_i_snow_status was a field on the cmdb_ci_computer table. That doesn't sound likely as that x_snsab shows that its in a different scope.
Why didn't you try to do what I talked about: Log out the values of the fields before you query for them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 03:47 PM - edited 09-01-2023 05:46 PM
@Uncle Rob How can i do that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 04:02 PM
Hi yoli1,
In your background script try
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('x_snsab_snow_sam_i_snow_status', 'Quarantined');
gr.query();
while (gr.next()) {
gr.operational_status = 'deactivated';
var result = gr.update();
gs.info(" Result from updating cmdb_ci_computer record is: " + result);
}
Is there a value 'deactivated' for the choice for that field 'operational_status'? and as Robert indicates, there may be some application scope related issues here. If you don't get the sys_id value in 'result', the update failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 04:50 PM
var dontUseGrAsAVariableName = new GlideRecord('cmdb_ci_computer');
dontUseGrAsAVariableName.addQuery('x_snsab_snow_sam_i_snow_status', 'Quarantined');
gr.query();
gs.info("Always check if you're actually selecting the right data before you start updating");
gs.info("This is how many we retrieved: " + dontUseGrAsAVariableName.getRowCount());