K1000 Round Robin
This pretty much will work for me but I was wondering how to add one more option. Would it be possible that this rule only works for people that I put in a "Round Robin" Label? We would not like everyone to be in the Round Robin group, just our first tier support.
I tested with this some but could not seem to get it to work the way I wanted it to.
Answers (4)
UPDATE HD_TICKET set HD_TICKET.OWNER_ID = (select BATTERUP.ID from (select O.ID from HD_TICKET T JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID JOIN USER O ON O.ID=UL.USER_ID JOIN USER_LABEL_JT ON UL.USER_ID = O.ID LEFT JOIN (select max(CREATED) MAXC, OWNER_ID, HD_QUEUE_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID, HD_QUEUE_ID) T2 ON O.ID=T2.OWNER_ID and Q.ID=T2.HD_QUEUE_ID LEFT JOIN (select USER_ID from USER_LABEL_JT UL2 JOIN LABEL OUTLABEL ON OUTLABEL.ID=UL2.LABEL_ID and OUTLABEL.NAME = 'Round_Robin') RR ON O.ID=RR.USER_ID /* Change Round_Robin to your Label Name*/ where O.BUDGET_CODE<> 'out' and RR.USER_ID != '' and T.OWNER_ID=0 and T.ID= ORDER BY MAXC ASC, RAND() LIMIT 1 ) BATTERUP) WHERE HD_TICKET.ID =
This update statement seems to work. I used a label called Round_Robin. This could be changed to your liking.
Select Statement
select HD_TICKET.ID from
HD_TICKET
JOIN HD_TICKET_CHANGE C ON C.HD_TICKET_ID=HD_TICKET.ID and C.ID=<CHANGE_ID>
WHERE
C.DESCRIPTION LIKE 'Ticket Created%'
and ( HD_TICKET.OWNER_ID=0 OR HD_TICKET.OWNER_ID IS NULL)
Update Statement
UPDATE HD_TICKET
set HD_TICKET.OWNER_ID = (select BATTERUP.ID from (select O.ID
from
HD_TICKET T
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID
JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID
JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID
JOIN USER O ON O.ID=UL.USER_ID
JOIN USER_LABEL_JT ON UL.USER_ID = O.ID
LEFT JOIN
(select max(CREATED) MAXC, OWNER_ID, HD_QUEUE_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID, HD_QUEUE_ID) T2
ON O.ID=T2.OWNER_ID and Q.ID=T2.HD_QUEUE_ID
LEFT JOIN (select USER_ID from USER_LABEL_JT UL2 JOIN LABEL OUTLABEL
ON OUTLABEL.ID=UL2.LABEL_ID and OUTLABEL.NAME = 'Round_Robin') RR ON O.ID=RR.USER_ID /* Change Round_Robin to your Label Name*/
where
O.BUDGET_CODE<> 'out'
and RR.USER_ID != ''
and T.OWNER_ID=0
and T.ID=<TICKET_IDS>
ORDER BY MAXC ASC, RAND()
LIMIT 1 ) BATTERUP)
WHERE HD_TICKET.ID =<TICKET_IDS>
UPDATE HD_TICKET
set HD_TICKET.OWNER_ID = (select BATTERUP.ID from (select O.ID
from
HD_TICKET T
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID
JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID
JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID
JOIN USER O ON O.ID=UL.USER_ID
JOIN USER_LABEL_JT ULJ ON ULJ.USER_ID = O.ID
JOIN LABEL L ON (L.ID = ULJ.LABEL_ID AND L.NAME = 'ROUND-ROBIN') -- add round robin label here
LEFT JOIN
(select max(CREATED) MAXC, OWNER_ID, HD_QUEUE_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID, HD_QUEUE_ID) T2
ON O.ID=T2.OWNER_ID and Q.ID=T2.HD_QUEUE_ID
LEFT JOIN (select USER_ID from USER_LABEL_JT UL2 JOIN LABEL OUTLABEL
ON OUTLABEL.ID=UL2.LABEL_ID and OUTLABEL.NAME='Out of office') OOO ON O.ID=OOO.USER_ID
where
O.CUSTOM_1<> 'out'
and OOO.USER_ID IS NULL
and T.OWNER_ID=0
and T.ID=
ORDER BY MAXC ASC, RAND()
LIMIT 1 ) BATTERUP)
WHERE HD_TICKET.ID =
Comments:
-
Hmm... Looks like its getting cut off...
The last line should have the "greater than" TICKET_IDS "LESS THAN" - dchristian 12 years ago -
It still does not quite work properly, I am using
UPDATE HD_TICKET
set HD_TICKET.OWNER_ID = (select BATTERUP.ID from (select O.ID
from
HD_TICKET T
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID
JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID
JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID
JOIN USER O ON O.ID=UL.USER_ID
JOIN USER_LABEL_JT ON UL.USER_ID = O.ID
JOIN LABEL L ON (L.ID = UL.LABEL_ID AND L.NAME = 'Round_Robin')
LEFT JOIN
(select max(CREATED) MAXC, OWNER_ID, HD_QUEUE_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID, HD_QUEUE_ID) T2
ON O.ID=T2.OWNER_ID and Q.ID=T2.HD_QUEUE_ID
LEFT JOIN (select USER_ID from USER_LABEL_JT UL2 JOIN LABEL OUTLABEL
ON OUTLABEL.ID=UL2.LABEL_ID and OUTLABEL.NAME='Out of office') OOO ON O.ID=OOO.USER_ID
where
O.CUSTOM_1<> 'out'
and OOO.USER_ID IS NULL
and T.OWNER_ID=0
and T.ID=
ORDER BY MAXC ASC, RAND()
LIMIT 1 ) BATTERUP)
WHERE HD_TICKET.ID =
I created a user label called Round_Robin. There are 3 people in the group for testing. It will not hand the tickets off. It sees the ticket come in but will not assign it.
If I remove JOIN LABEL L ON (L.ID = UL.LABEL_ID AND L.NAME = 'Round_Robin') the tasks works fine but it will pick anyone that has ticket privileges . - young020 12 years ago
Comments:
-
Yes, the select statement builds at the Queue level. We have a couple of different teams (ServiceDesk & Telecom) sharing this queue, each with their own label. I've also built rules that look at the Queue AND the Category selection with the Category added to the Select statement above. - jmarotto 12 years ago
We use two different labels (one for each of the above named groups) to sort this out.
Select =
select HD_TICKET.*
from HD_TICKET
where HD_TICKET.OWNER_ID = 0
and HD_TICKET.HD_QUEUE_ID= 1
Update =
update HD_TICKET
set HD_TICKET.OWNER_ID = (select USER_ID from (select T.ID, O.ID USER_ID, O.USER_NAME, MAXC, IF(MAXC IS NULL, 1, 2) BATTERUP
from HD_TICKET T
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID
JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID
JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID
JOIN USER O ON O.ID=UL.USER_ID
LEFT JOIN (select max(CREATED) MAXC, OWNER_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID) T2 /* create table of all owners' oldest tickets created today */
ON O.ID=T2.OWNER_ID
where O.ID
not in (select ULJT.USER_ID
from USER_LABEL_JT ULJT
join LABEL L on L.ID=ULJT.LABEL_ID
where L.NAME like 'U-Out of office') /* exclude members of this label from selection */
and O.ID
not in (select ULJT.USER_ID
from USER_LABEL_JT ULJT
join LABEL L on L.ID=ULJT.LABEL_ID
where L.NAME like 'U-Queue Manager') /* exclude members of this label from selection */
ORDER BY MAXC ASC, RAND()
) BATTERUP2
where
USER_ID
in (select ULJT.USER_ID
from USER_LABEL_JT ULJT
join LABEL L on L.ID=ULJT.LABEL_ID
where (L.NAME like 'U-T1 Service Desk' /* or '%T1 Service Desk%' */) ) /* narrow selection further to members of these labels for routing to work units in the same queue */
limit 1)
where
(HD_TICKET.ID in (
Comments:
-
I'm not sure why my code isn't workin;
UPDATE HD_TICKET
set HD_TICKET.OWNER_ID = (select BATTERUP.ID from (select O.ID
from
HD_TICKET T
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID
JOIN HD_QUEUE_OWNER_LABEL_JT QOL ON QOL.HD_QUEUE_ID=Q.ID
JOIN USER_LABEL_JT UL ON UL.LABEL_ID=QOL.LABEL_ID
JOIN USER O ON O.ID=UL.USER_ID
JOIN USER_LABEL_JT ULJ ON ULJ.USER_ID = O.ID
JOIN LABEL L ON (L.ID = ULJ.LABEL_ID AND L.NAME = 'Test Label') -- add round robin label here
LEFT JOIN
(select max(CREATED) MAXC, OWNER_ID, HD_QUEUE_ID from HD_TICKET WHERE CREATED > CURDATE() GROUP BY OWNER_ID, HD_QUEUE_ID) T2
ON O.ID=T2.OWNER_ID and Q.ID=T2.HD_QUEUE_ID
LEFT JOIN (select USER_ID from USER_LABEL_JT UL2 JOIN LABEL OUTLABEL
ON OUTLABEL.ID=UL2.LABEL_ID and OUTLABEL.NAME='Out of office') OOO ON O.ID=OOO.USER_ID
where
O.CUSTOM_2 'Out and About'
and OOO.USER_ID IS NULL
and T.OWNER_ID=0
and T.ID=
ORDER BY MAXC ASC, RAND()
LIMIT 1 ) BATTERUP)
WHERE HD_TICKET.ID = "greater than" TICKET_IDS "LESS THAN"
I have a test label for my queue and I made the Out and About field in Custom Field 2...I'm very new to SQL so I'm not sure what to look for exactly. - volcy 12 years ago