Clarity

 View Only
  • 1.  GEL Script Email Notification

    Posted Jun 22, 2020 12:04 PM
    Hello Everyone, 

    I am writing a GEL Script to send a notification IT Manager and Business Manager. If IT Manager is present, the email goes to go to only IT Manager. If IT Manager is not present, the email has to go to only Business Manager. If both are present, it has to go only IT Manager. 

    I wrote a script but it is kind of stuck when both are present. Here is the code script alone that where I am mixing things.

    Any thoughts ? 

    <core:if test="${result2.rowCount > 0}"><core:if test="${result2.rowCount > 0}">     <core:forEach items="${result2.rows}" trim="true" var="row2">
                <gel:log trim="false"> Sending Email...${row2.ProjectID} Email Recipient: ${row2.pmemail}${row2.itpmemail}</gel:log>                <core:catch var="mailException">                        <gel:email from="PPM Admin" subject="PPM Reminder Email - Resource Hours" to="${row2.pmemail}${row2.itpmemail}"> <![CDATA[ <html> <head> <meta charset="UTF-8"> <style> #emailBody { font-family : Calibri, arial; font-size: 14px; } </style> </head>
    <body><div id="emailBody"> Dear ${row2.resName},<br/> <br/> ]]> <core:choose> <core:when test="${row2.itpmid != null and row2.pmid == null}"><![CDATA[  This is a general reminder to enter allocation hours.  ]]> </core:when> <core:when test="${row2.itpmid == null and row2.pmid != null}"><![CDATA[  This is a general reminder to enter allocation hours. ]]> </core:when> </core:choose>
    <![CDATA[ <br/> <br/> <strong>Note: </strong> This is a system generated email. Please do not reply. </div>      </body> </html> ]]>                 </gel:email>            </core:catch>
                <core:if test="${!empty mailException}">                <gel:log>${mailException}</gel:log>            </core:if> 
            </core:forEach> </core:if>


  • 2.  RE: GEL Script Email Notification
    Best Answer

    Posted Jun 23, 2020 01:25 AM
    Edited by Christopher Hackett Jun 25, 2020 06:30 PM
    My first choice would be to solve it in your query.

    I see you have: ${row2.pmemail}${row2.itpmemail}

    Where:
    pmemail = business manager
    itpmemail = it manager

    So in your query I would do something like:

    select 
    ...
    case when itpmemail is null then pmemail else itpmemail as recipient
    ...
    from
    ...​


    Then in your email: to="${row2.recipient}"

    You can do similar things with other fields for name etc.

    If however you can't modify the query for some reason, you can use vars in the script like so:

    <core:set var="recipient" value="${row2.pmemail}" />
    <core:if test="${!empty(row2.itpmemail)}">
      <core:set var="recipient" value="${row2.itpmemail}" />
    </core:if>
    
    <gel:email ... to="${recipient}">


    You can do this similarly with your itpmid / pmid variables.  If the query is returning an actual null value when the result isn't present, then testing for empty(var) and !empty(var) should suffice as null / not null checks on them.


  • 3.  RE: GEL Script Email Notification

    Posted Jun 23, 2020 05:29 AM
    Hello Arunachalam,

    Multiple receiver email addresses are needed to be separated using semicolon. 


    ------------------------------
    Clarity PPM Consultant
    Pemari Technology
    ------------------------------



  • 4.  RE: GEL Script Email Notification

    Posted Jun 23, 2020 10:21 AM
    Semi-colon is preferred, but:

    Semi-colon, comma, or a space, all may be used as delimiters - just be consistent and don't mix/match within the same email tag.  Whatever is used as the delimiter should be only used as a delimiter, and the other delimiters should not be present at all.

    It's also feasible that the delimiter was included in the GEL variable value already.  We cannot see from the information given, but if it was included, that would be sufficient.