Topic
2 replies Latest Post - ‏2013-11-26T08:24:40Z by raj_kgdr
raj_kgdr
raj_kgdr
62 Posts
ACCEPTED ANSWER

Pinned topic email notification hook based on application to respective groups

‏2013-11-13T04:28:40Z |

Dear All,

Hope you doing well.

I wrote a piece of code, but don't see the expected result. Please Help.

The situation is I need an email to be sent to respective groups based on the applications. We have groups set for different application.

The code looks like :

set querydef = session.BuildQuery("Users")
querydef.BuildField("fullname")
querydef.BuildField("email")
set resultset = session.BuildResultSet(querydef)
set operator = querydef.BuildFilterOperator(AD_BOOL_OP_AND)
 
If GetFieldValue("DR_Type").GetValue() = "Post" then
operator.BuildFilter "groups", AD_COMP_OP_EQ, "Post_Test"
end if
 
If GetFieldValue("DR_Type").GetValue() = "Medic" then
operator.BuildFilter "groups", AD_COMP_OP_EQ, "Medic_Test"
end if

set resultset = session.BuildResultSet(querydef)

resultset.execute
status1 = resultset.MoveNext
   
Do While status1 = AD_SUCCESS
 
if resultset.GetColumnValue(1) <> "" and resultset.GetColumnValue(2) <> "" then
mailmsg.AddTo email1
end if
status1 = resultset.MoveNext
Loop
subj =  GetFieldValue("DR_Id").GetValue & _
       ": " & GetFieldValue("DR_Type").GetValue
        mailmsg.SetSubject subj
 
 
         body = "Dear All" & "," & NL & NL & _
        "Please be informed of the below DR which is CLOSED" & NL & NL & _
        "DR ID          : " & GetFieldValue("DR_ID").GetValue & NL & _
        "Current State   : " & GetFieldValue("State").GetValue & NL & _
        "DR Type        : " & GetFieldValue("DR_Type").GetValue & NL & _
        "Headline        : " & GetFieldValue("Short_Description").GetValue & NL & _
        "Description     : " & GetFieldValue("Full_Description").GetValue & NL & _
        "Requestor Name  : " & GetFieldValue("Requestor_Name").GetValue & NL & _
        "Date Created    : " & GetFieldValue("Date_Created").GetValue & NL & _        
        "Implementor     : " & GetFieldValue("Implemented_By").GetValue & NL & _
        "Implement Date  : " & GetFieldValue("Implement_Date").GetValue & NL & _
        NL & NL & "Thanks," & NL & "CQ Administrator"
flag = True
     End If
        ' End If
    If flag = True then
       body = Replace(body, vbNl & "." & vbCr, vbNl & ".." & vbCr)
       mailmsg.SetBody body
       mailmsg.Deliver
    End If
    Set mailmsg = Nothing
    Set sessionObj = Nothing

 

Updated on 2013-11-13T04:30:26Z at 2013-11-13T04:30:26Z by raj_kgdr
  • DonaldN
    DonaldN
    223 Posts
    ACCEPTED ANSWER

    Re: email notification hook based on application to respective groups

    ‏2013-11-13T05:27:30Z  in response to raj_kgdr

    Just had a quick look, the code "mailmsg.AddTo email1" is supposed to set the email address to the "To:" field, but I did not see the variable "email1" got assigned a value. Simple mistake?

    • raj_kgdr
      raj_kgdr
      62 Posts
      ACCEPTED ANSWER

      Re: email notification hook based on application to respective groups

      ‏2013-11-26T08:24:40Z  in response to DonaldN

      Indeed!! And I corrected that and its working now.

      I thank you :-)