Is there a way to set the Owner to the one logged in when the ticket is changed to "Open"?
We noticed you have to change both at the same time and wondered if there is a way to make it either set the status to "Open" when the user changes the Owner to themselves or changing the status to "Open" changes the Owner to the logged on user.
0 Comments
[ + ] Show comments
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
h2opolo25
10 years ago
This changes the status of tickets marked as New to Opened when the owner changes the Owner to themselves.
select distinct HD_TICKET.ID,
HD_TICKET.OWNER_ID as OWNER_ID,
HD_TICKET.ID as TICKNUM,
HD_TICKET.TITLE,
HD_STATUS.NAME AS STATUS_NAME,
HD_STATUS.STATE as STATE,
OWNER.USER_NAME as OWNER_NAME,
OWNER.FULL_NAME as OWNER_FULLNAME,
OWNER.EMAIL as OWNER_EMAIL,
UPDATER.USER_NAME as UPDATERNAME,
UPDATER.EMAIL as UPDATEREMAIL
from (HD_TICKET, HD_STATUS)
left join HD_TICKET_CHANGE on HD_TICKET_CHANGE.ID = <CHANGE_ID>
left join HD_TICKET_CHANGE_FIELD on HD_TICKET_CHANGE_FIELD.HD_TICKET_CHANGE_ID = HD_TICKET_CHANGE.ID
left join USER OWNER on OWNER.ID = HD_TICKET.OWNER_ID
left join USER UPDATER on UPDATER.ID = HD_TICKET_CHANGE.USER_ID
where HD_STATUS.ID = 4 <--status ID for New
and HD_TICKET_CHANGE.HD_TICKET_ID= HD_TICKET.ID
and HD_TICKET_CHANGE_FIELD.FIELD_CHANGED = 'OWNER_ID'
and UPDATER.ID = OWNER.ID
Update SQL:
update HD_TICKET as T, HD_STATUS as STATUS
set T.HD_STATUS_ID = 1, <--status ID for Opened
T.TIME_OPENED = IF(STATUS.STATE = 'opened', NOW(), T.TIME_OPENED),
T.TIME_CLOSED = IF(STATUS.STATE = 'closed', NOW(), T.TIME_CLOSED),
T.TIME_STALLED = IF(STATUS.STATE = 'stalled', NOW(), T.TIME_STALLED)
where T.HD_QUEUE_ID = STATUS.HD_QUEUE_ID
and (T.ID in (<TICKET_IDS>))
OnTicketSave