WARNING: Always review "Precautions when creating ticket rules" before writing any rules. NOTE: You may need to also read "Importing a Custom Ticket Rule"
Overview
Some customers want to set the status to a stalled state like "waiting oN Customer" when the ticket owner makes a comment. In 5.0 we can easily obtain the "before value" of all fields in the helpdesk and thus it is possible to detect the context under which that comment was made. Therefore, we can make certain assumptions that are true a very high percentage of the time.
In this case we are going to assume that IF:
- a comment is not "owners only" (meaning end-user/customer can see it)
- the owner did not change the status
- the ticket is not already in a "waiting on customer" state
THEN :
- We will automatically change the status of the ticket to "waiting on customer"
Rule Details
Frequency
On Ticket save
Select Query
- Note that if you are using a different status then change it at the end of the query
- Note that the link for "view ticket search results" in the rule will not work for this rule.
select C.ID
FROM HD_TICKET JOIN HD_TICKET_CHANGE C ON C.HD_TICKET_ID=HD_TICKET.ID and C.ID=<CHANGE_ID>
JOIN HD_STATUS S on HD_STATUS_ID=S.ID
JOIN HD_TICKET_CHANGE_FIELD FCOM ON FCOM.HD_TICKET_CHANGE_ID=C.ID and FCOM.FIELD_CHANGED='COMMENT'
LEFT JOIN HD_TICKET_CHANGE_FIELD FSTAT ON FSTAT.HD_TICKET_CHANGE_ID=C.ID AND FSTAT.FIELD_CHANGED='STATUS_NAME'
WHERE
FSTAT.ID IS NULL
and OWNERS_ONLY=0
and S.NAME<>'Waiting On Customer'
Comment
Not necessary as the update will take care of it
Update Query
- Note that if you are using a different status then change it at the end of the query
update HD_TICKET as T JOIN HD_TICKET_CHANGE C ON C.HD_TICKET_ID=T.ID
JOIN HD_STATUS S ON T.HD_QUEUE_ID=S.HD_QUEUE_ID
JOIN HD_STATUS S_OLD ON HD_STATUS_ID=S_OLD.ID
set DESCRIPTION=CONCAT(DESCRIPTION,'\nOwner Reply Triggered a Status Change. [Rule]\nChanged ticket Status from "',S_OLD.NAME,'" to "',S.NAME,'"'),
HD_STATUS_ID=S.ID
where
S.NAME='Waiting On Customer' and
(C.ID in (<TICKET_IDS>))