When a decision task is taken and Denied this is successfully triggering an email to the affected user based on the Denied sub process and associated Task. Approved decisions are not triggering an email, Approvals don’t generate a sub process they just simple move the process onto the next task. Each task is different depending on the process so I cannot effectively hang an approval email from those. Is there some way to trigger an email based on the ‘Answer’ to a decision?
Hi,Â
Yes you can trigger an email to fire on the action processor, we do this by using checkAnswer:
Â
{Â
       Send Mail to affected user Decision Approval Received ]],Â
      /> EVENT_TYPE == "d"
         and ACT_TYPE_SC == "CLOSURE"Â
         and (CATEGORY_SC == "DECISION" or
         CATEGORY_SC == "AUTHORIZATION" orÂ
         CATEGORY_SC == "APPROVALS")
         and checkAnswer("Yes", EVENT_ID) ]],Â
      strSendMailV2 .. "TEMPLATE=SM_INTERNAL_APPROVAL_RECEIVED RECIPIENTS=TO_AFFECTED", Â
      "continue" Â
  },
Hope this helps you.Â
Â
Kev
Thanks
Additionally should have added that Check Answer is a function, this is added at the bottom of our action_processor_rules_conf.lua
Â
function checkAnswer(parmAnswer, parmEventId)
   local sSql = l SELECT
      answer 'ANSWER'
      FROM rproc_task
      INNER JOIN rproc_dtl
      ON rproc_task.rproc_dtl_id = rproc_dtl.rproc_dtl_id
      INNER JOIN rproc_decisionsÂ
      ON (rproc_decisions.rproc_task_id = rproc_task.rproc_task_id
         and rproc_decisions.rproc_decision_id = rproc_task.answer_id)
      WHERE
      rproc_task.incident_id = ]] .. parmEventId
     Â
   local result,err = DB:sql(sSql)
   if err thenÂ
      LOGGER:error("Error in SQL when checking for Decision Answer. Error: " .. (err or "??") .. "\nSQL: " .. stringify(sSql))
      return
   end
  Â
   if result.'ANSWER']:upper() == parmAnswer:upper() then
      return true
   else
      return false
   end
endANSWER_VALUE = ""
function getDecisionAnswer(eventId, actRegId,ans, rmks)
   local actRegId = actRegId or 0
   local ans = ans or ""
   local ok,err = DB:sql(,a
         SELECT answer 'ANSWER_VALUE'
         FROM act_reg
         INNER JOIN rproc_task ON rproc_task.incident_id = act_reg.incident_id
         INNER JOIN rproc_dtl ON rproc_dtl.rproc_dtl_id = rproc_task.rproc_dtl_id
         INNER JOIN rproc_decisions ON rproc_task.rproc_task_id = rproc_decisions.rproc_task_id
         WHERE answer = ']] .. ans .. c_'
         AND act_reg.act_reg_id = ]] .. actRegId
         )
   if err thenÂ
      LOGGER:error("Error in SQL when checking for Decision Answer. Error: " .. (err or "??"))
      return
   end
   if ok and ok "ANSWER_VALUE"] and (okÂ"ANSWER_VALUE"] or "") ~= "" then
      local ANSWER_VAR = ok "ANSWER_VALUE"]
      LOGGER:info("Ready to run external command for " .. actRegId .. ": " .. strETMNoUser .. "'ECC Make Decision' EventID='" .. eventId .. "' Answer='" .. ANSWER_VAR .. "' Remarks='" .. rmks .. "';")
      os.execute(strETM .. "'ECC Make Decision' EventID='" .. eventId .. "' Answer='" .. ANSWER_VAR .. "' Remarks='" .. rmks .. "';")
      -- return ok."ANSWER_VALUE"]
      return
   else
      return
   end
end
Since you will only have a single stage created after the Approval, you can use an AP rule to trigger SmartMail based on that stage action on the parent event. The sample rule below could be extended if needed to only send on certain workflows or offerings.
   {
     Send Mail to affected user Decision Approval Received ]],Â
     (EVENT_TYPE == "r" or EVENT_TYPE == "s")
      and ACT_TYPE_SC == "POST APPROVAL STAGE SC"Â
      ]],Â
     strSendMailV2 .. "TEMPLATE=SM_INTERNAL_APPROVAL_RECEIVED RECIPIENTS=TO_AFFECTED", Â
    "continue" Â
  },
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.