How to assign using scripts in assignment rules for vulnerability response?

Kruthik M Shiva
Tera Contributor

Hi all,
I have a requirement where if configuration item->IT application owner is not empty it should be assigned to IT application owner for this i cannot assign using user group or user group field , the only way is to through scripts what should be the script for assigning to IT application owner using script?

Thanks in advance,

1 ACCEPTED SOLUTION

Muralidharan BS
Mega Sage
Mega Sage

HI Kruthik,

You can try this in your lower instance and proceed. 

1. Go to Vulnerability response > assignment rules

2. Open the rule you want to amend or create new

3. Add the condition to filter the vulnerability. 

4. Choose to assign using "script"

Paste the below script and try it. 

Check the field name managed_by_group and managed_by are oob fields to assign ownership if this is not the field you are using, change the field value correctly. 

current.assignment_group = current.cmdb_ci.managed_by_group // assignment group
current.assigned_to = current.cmdb_ci.managed_by // assigned to person

 

Thanks

 

 

 

 

 

View solution in original post

8 REPLIES 8

Muralidharan BS
Mega Sage
Mega Sage

HI Kruthik,

You can try this in your lower instance and proceed. 

1. Go to Vulnerability response > assignment rules

2. Open the rule you want to amend or create new

3. Add the condition to filter the vulnerability. 

4. Choose to assign using "script"

Paste the below script and try it. 

Check the field name managed_by_group and managed_by are oob fields to assign ownership if this is not the field you are using, change the field value correctly. 

current.assignment_group = current.cmdb_ci.managed_by_group // assignment group
current.assigned_to = current.cmdb_ci.managed_by // assigned to person

 

Thanks

 

 

 

 

 

Thank you so much I will be trying it in the lower instance and update on your solution 

Thanks also make sure if the user is member of assignment group. 

Hi,

Murali is correct. I would like to add an important point to scripted assignments: A default Assignment Group.

When rules like Assignment Rules run in ServiceNow and the Condition is met, the Rule expects an Assignment Group. Said a different way, once a match is found VR stops processing the Assignments Rules and it expects an Assignment Group to be provided. If there is no assignment group provided, the VIT is not assigned to any group and is unassigned.

Typically in non-scripted assignments, you build into the condition a check to ensure that the Support Group that you are using is not empty, otherwise does match and you have a default catch-all rule at the end to capture any missed items.

With Scripted Assignment Rules, you need to provide a Default Assignment Group if your lookup script is unsuccessfully in returning an assignment group for any reason. If you don't the VIT will not be assigned to any assignment group.