Vulnerable Item assignment rule script

sarahjantz
Tera Expert

We are looking to refine one of our VR assignment rules to take it a step further and not just assign to an assignment group, but also the assign it to the user contained in the assigned_to field on the CI record. Can anybody help me with the script necessary to accomplish this? We'd want to call out in the script assigning it to a specific group and then also assigning to the assigned_to if the field is not empty. 

1 ACCEPTED SOLUTION

sarahjantz
Tera Expert

For the record, this is what ended up working:

 

current.assigned_to = current.cmdb_ci.assigned_to;
current.assignment_group = 'inserts sys ID here';

View solution in original post

5 REPLIES 5

Yousaf
Giga Sage

Hi Sarah,

Try something like this.

var vul = new GlideRecord('sn_vul_vulnerability');

vul.addQuery('active=true');

vul.query();

while (vul.next())

{

var gr = new GlideRecord('cmdb_ci');

gr.addQuery('sn_vul_vulnerability',vul.getValue('sys_id'))

gr.query();

if (gr.next())

{

vul.assignment_group =<assignment group field name>;

vul.assigned_to = gr.<assigned to field name>;

vul.update();

}

}

 

Mark Correct or Helpful if it helps.

Thanks,
Yousaf


***Mark Correct or Helpful if it helps.***

Thanks for your reply. I wasn't able to get this to work. 

Harish KM
Kilo Patron
Kilo Patron
Hi assuming your assignment rule is on vulnerability table Var vn = new GlideRecord ('cmdb_ci'); vn.addQuery('sys_id',current.cifieldnam); vn.query(); if(vn.next()) { current.assignment_group = vn.assignment_group; current.assigned_to = vn.assigned_to; }
Regards
Harish

Thanks for your reply. I wasn't able to get this to work.