Set Request, RITM, and SCTASK priority depending on selection on drop down list within the catalogue item

Harry Smith
Giga Contributor

Hi Community,

 

I want to setup a rule which will set the priority of a REQ, RITM, and SCTASK to P2 if the user selects "Health and Safety" from a drop down on the Service Portal when submitting a certain item, however I can only find how to select the option when the business rule is pointing at the SCTASK table. This unfortunately though doesn't seem to affecting the priority at all.

I thought that I could instead point it at the REQ and then the priority would be carried down to the RITM and SCTASK but can't see how to point the conditions at an option in the drop down list.

 

Does anyone have any ideas how I can do this?

 

Many Thanks,

 

Harry Smith

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

You'll need a script in your business rule to do this.  When a request is submitted, the REQ is created first, then the RITM close behind it.  SCTASK(s) are only created as your workflow dictates, or if you allow manual creation from the related list on the RITM.  It sounds like it will be best to have the business rule running before insert on the sc_req_item table.  The script will set the priority based on this variable, then Glide to the REQ to do the same.  You can then create a second business rule before insert on sc_task to set the priority to that of its RITM.

So for the first rule on sc_req_item, the script would look something like this - depending on your variable name and the Value of the choice list item (can be different from the Text/label)

(function executeRule(current, previous /*null when async*/) {
	if(current.variables.variablename == "choice list Value"){//replace variablename and choice list Value
		current.priority = 2;
		//now lookup the REQ attached to this RITM and set its Priority to the same
		var req = new GlideRecord('sc_request');
		req.addQuery('sys_id', current.request);
		req.query();
		if(req.next()){
			req.priority = 2;
			req.update();
		}
	}
})(current, previous);

You can specify an Item in the Filter Conditions, so that this rule only runs for this item - or it won't do anything otherwise if that variable name and value isn't found in other items.

For the business rule running before insert on sc_task, with the Filter Condition Request Item.Item is <<this catalog item>>, on the Actions tab you can Set filed values Priority Same as Request item.Priority.  In case you're not familiar, these 2 references to Request Item. another field are found by showing the Related Fields at the bottom of the fields list, then selecting the field within the Request Item fields.

Not the OP, but I implemented this and it works like a charm! Thank you!

Glad I could help!

 

Connect with me www.linkedin.com/in/brad-bowman-321b1567

Brad Bowman
Kilo Patron
Kilo Patron

Were you able to try this solution?  Please update the post so that others will see the correct answer.