Options for Business rule to set assignment group, Category and Sub Category

llbcdl
Giga Contributor

Hello,

I created an on display business rule that will set the Assignment group, Category and sub category for users in a specific department. I used filter conditions to look for the department and actions to set the field values, I didn't script this.

This works great, until one of those users needs to open an incident that should be assigned to another assignment group with a different Category and Sub category. I can't change the fields without the BR reverting them back when I update the incident. Is there a way to have it set the Assignment group, Category and Sub Category by default but then allow the user to change it before submitting the incident? This is also happening if one of the users in the aforementioned department Submits a record producer to create an incident. The Business rule overrides the RP settings.

The intention of the Business rule was to pre populate the fields as a convenience for the department when they submit incidents assigned to their department. The issue arises when they need to submit an IT incident that gets assigned to an IT group. 

Is there a better way to do this?

Thank you,

Charles 

 

 

1 ACCEPTED SOLUTION

Sorry for the delay, thanks for posting the template strings.  Here is your solution/edits to your existing business rule.  Because we need to call the current.isNewRecord() API call, this requires that we make the business rule an "advanced" one and scripting is required.  This is because we cannot check whether the record "is new record" in the filter conditions and we have to utilize the Condition script field instead.

  • At the top of your business rule check the Advanced checkbox
  • On the When to run tab:
    • Uncheck insert and update
    • Set When to display
    • Click the X beside all of your conditions to remove all filter conditions.  This tab should now look like this
    • find_real_file.png
  • On the Actions tab, click the X beside all set field values to remove all of those settings. This tab should now look like this:
  • find_real_file.png
  • On the Advanced tab:
    • Set the Condition to the following:
    • current.isNewRecord() && ["5d9bd582db21ff40b2b77b668c961929", "aee387e8db720b003d3d7d568c961949","11bde863db4aeb40918dff971d961996"].indexOf(current.opened_by.department.toString()) > -1
    • Then paste in the following script:
(function executeRule(current, previous /*null when async*/) {
	/*
 	* This business rule runs only on a new incident when the Opened By User's Department is:
 	* Business Intelligence, Business Application Support (cannot see entire name), or Business Application Support (cannot see entire name)
 	*/
	
	current.assignment_group = "773a332ddb281f405cbf7d598c9619fe"; //SN_BusinessIntelligence
	current.category = "reports";
	current.contact_type = "self-service";
	
})(current, previous);

That should do it!  Since this business rule now runs only on display, your record producers, integrations, etc that create/update incidents in the background won't be affected.  And because the condition contains current.isNewRecord() this will only fire when the user clicks New incident versus firing on existing incidents.

 

Please mark this post or any as helpful or the correct answer if applicable so others viewing may benefit.

View solution in original post

17 REPLIES 17

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Charles, I assume this is also for new records only correct?  If so you could add a condition to check if its a new record as there is an API for that.  If this is the case I would need to see your business rule (screenshots) to help you set it up to use this API call.

current.isNewRecord()

llbcdl
Giga Contributor

find_real_file.pngfind_real_file.png

Got it thanks.  You had mentioned this was a display business rule but this is really just a Before Insert AND Update.  If you only want this to happen on new records you need to uncheck Update so this only happens on new (inserted) incidents.

Now some additional questions:

1. Do you want this to happen on display so they can overwrite the values set such as assignment group, category and contact type?

2. Or do you prefer these get set when they click submit?  If this method then I would suggest adding another condition on the When to Run tab to say that Assignment Group is empty.  This way the assignment is only set if they hadn't already filled it in.

Originally it was a display until I modified it for troubleshooting. 

I'm not sure either question applies. 

The Business Intelligence group would like to be able to open an incident to work on reports. The ask was when they open the incident, it populated the fields to auto assign to their group. 

The downside came after we implemented and they started submitting incidents through a record producer on the Service Portal. ALL their incidents were assigned to SN_BusinessIntelligence even though the RP should have assigned to SN_Helpdesk. With the Business rule active, we can't change the assigned to, Category or Sub category as soon as you hit save it reverts back to sn_BusinessIntelligence with the category and sub category assigned by the business rule. 

What I would like is for the Record producer to assign incidents to SN_Helpdesk as designed. When Business Intellegence opens an incident using Create new incident i'd like for it to pre populate the fields as the business rule is designed, but they have the option to change the fields if needed. 

I want the business rule but I don't want it to be "sticky".

 

 

 

Based on what you describe you are choosing option 1 🙂

 

Business rules are executed regardless where the incident is submitted from: Create New Incident, Record Producer, etc.  So this is why this BR is affecting your record producer submissions as well.  So to get past this we need to default these values on display when they create a new incident.

 

To do this though unfortunately this business rule will have to be a script instead of using conditions and set values.  With a script I will need to know the SysID's of the departments in your current condition.  To easily get this do me a favor and...

  • Pull up the business rule that you currently have
  • Click the hamburger or right click on the header and choose Show XML
  • This will popup a new window with the raw XML of your business rule.  Find the filter_condition tag and paste the contents of it into a response here.  Please paste the actual contents and not a screenshot as I will need values from it in the script I will provide back to you and I don't want to retype a 32 character SysID.  All I need is the filter condition and not the entire XML.

find_real_file.png