- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2018 05:31 AM
Hello,
Most of our incidents are opened using SolarWinds integration. We are assigning CI to each Incident and we want to auto-populate CIs Company and Contract fields in the Incident form. I am thinking about Business rule but is it the best way to do it? And if it is do I need to use script to populate this fields?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2018 05:38 AM
If the incidents are being opened automatically via the integration then the best option is a before insert business rule. It should be a fairly simple rule, you just need to change the company and contract to a value that you can dot-walk to via the CI field.
current.company = current.cmdb_ci.company;
current.contract = current.cmdb_ci.ast_contract;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2018 07:18 AM
Company field is OK - it is auto populated using Business rule but Contract field stays empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 12:14 AM
I'm not familiar with the contract_rel_ci table so i can't really advise you on that front.
if your CI is linked to the contract via that table rather than a direct reference field then you'll need to glide into that table, find the right record and return the contract detail from there. The script below is the logic but i don't know if the field names are correct.
var gr = new GlideRecord('contract_rel_ci');
gr.addQuery('cmdb_ci', current.sys_id);
gr.query();
while(gr.next()){
var contract = gr.getValue('ast_contract');
current.ast_contract = contract;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 04:06 AM
I think that the following code is working. Is it OK?
ci_item and contract are column names in contract_rel_ci table.
var gr = new GlideRecord('contract_rel_ci');
gr.addQuery('ci_item', current.cmdb_ci);
gr.query();
while (gr.next())
{
var contract = gr.getValue('contract');
current.contract = contract;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2018 06:15 AM
If it works, then it is good 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2018 05:39 AM
HI,
You can use before insert business rule to populate the same. Yes you need to use glide record class to populate the CI company and contract to incident.