Vancouver - what script would you use... assignment of task to assignment group based off location

JennyBell
Tera Contributor

Hello - newbie to SN and coding here 🙂

 

I've been given several examples of scripts to use, but I have one situation where I need the following to happen:

Example:  Customer's main office is Frankfurt, but is traveling to Berlin.  Customer is requesting specific hardware pieces be available in his visitor office in Berlin.

 

Hardware Request catalog item has a "Current Location" field which pulls from the cmn_location table.   Current location is in this example Berlin (not his main office - so cannot use sys_user table for location assignment).  I need to assign the catalog task to deliver the requested hardware to his office in Berlin. I have a script which works if we are assigning to the customer's main location, but I need this script to assign based on the custom field "current location".

 

The attached script is saying if the customer chooses a current location, then assign to the support group (using the sys_id).

 

I also have created assignment rules for those catalog items /incidents are based of the user's main location (location in the user's record).  - This works great, but not sure I can some how create an assignment rule for the specific catalog items where they are in a different location.

 

Sorry to be so long winded - but really need some help here.  Thanks!

 

Jen 

2 REPLIES 2

Sumanth16
Kilo Patron

Hi @JennyBell ,

 

You have two options:

Using sysrule_assignment (Assignment under Left Hand Menu) to specify your conditions. This would help you centralize all assignment rules in one place, instead of spreading across different workflows or flows.

Condition will be catalog task --> Requested Item --> Requested for --> Location

Sumanth16_0-1710540086537.png

 

(or)

 

You can do this in the catalog task activity itself if you are using a  workflow using script like below 

Check the advanced check and you can try this script given below 

if(gs.getUser().getLocation() == "your_location_record_sys_id")
	{
		task.assignment_group = "your_assignment_group_sys_id";
		
	}

Sumanth16_1-1710540115148.png

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Hi Sumanth,

 

Thank you for your response.  I already have assignment rules based on a Requested for location Unfortunately, in my situation the assignment rules do not work because the user is visiting a different location and needs something from that office - not his normal office - hence the current location field.

 

Is there something I need to do to stop it from looking at the Requested for location and to just look at the Current Location field. Something like - "if requested for location is different than current location field selection, assign to current location field selection support group"  For example:  Farmer Ted's requested for location is New York, but his current location is Berlin, then assign to Support-Berlin.