Clarity

Expand all | Collapse all

GEL:  Email to Group

  • 1.  GEL:  Email to Group

    Posted Jan 10, 2011 06:46 PM
    Hi,
    I am attempting to "email" a group rather than an individual in a GEL script. For the "jobs/processes" there is an option to notify a "person" or a "group". Does anyone know how I'd change the syntax to do this?

    I have a group defined in Clarity as "TRG_EMAIL_Notification".... How would I put this "group" as the recipient?


    <gel:email from="clarity@regence.com" fromName="Clarity"
    to="${row.ManagerEmail}" subject="Clarity Message">

    </gel:email>




    Thanks,
    Lowell Wetzel


  • 2.  RE: GEL: Email to Group

    Posted Jan 11, 2011 04:19 AM
    Not sure that you can do that simply - the GEL email thing is a pretty simple dumb email client.

    2 ways to fix that;

    In your GEL, code it to retrieve the email addresses of all the group members then email all of them (this is not separate emails though, just one email with multiple recipients - (just semi-colon delimited in the "to" bit of the GEL:email thing))

    Define a group in your email system, send the mail to that group address. (More messy I think)


  • 3.  Moving to Clarity XOG/GEL/WSDL  board

     
    Posted Jan 12, 2011 06:42 PM
    Moving to Clarity XOG/GEL/WSDL board


  • 4.  RE: GEL: Email to Group

    Posted Jan 14, 2011 06:58 AM
    Hi,

    I am capturing with SQL the emails names by group and I use the script below. For exemple: If the group had 3 or 4 names, do not have problem, but if the group had more than 10 names, I include more 1,2,3... (depending the number of emails) tags "${SQLname.rows[-].inc}". You can put about 20 tags and it will be working.

    <gel:email from="${vs_from}" to="${SQLname.rows[0].inc};${SQLname.rows[1].inc};${SQLname.rows[2].inc};${SQLname.rows[3].inc};${SQLname.rows[4].inc};${SQLname.rows[5].inc};${SQLname.rows[6].inc};${SQLname.rows[7].inc};${SQLname.rows[8].inc};${SQLname.rows[9].inc}" subject="Project: ${vs_name}. Clarity ID: ${vs_code}">

    This is a test sending email to Group by Process using GEL Script.

    </gel:email>


    I hope help you.
    Marcio.


  • 5.  RE: GEL: Email to Group

    Posted Jan 14, 2011 03:10 PM
    Part of the reason I asked the question is that in the scheduling of "jobs", you can notify a "resource" or a "group". The limit of 20 values does not appear to be a problem in the jobs' notification for groups.

    I think I'll use the idea to query the "group"... but, now, I don't know how to "concatenate" a string using GEL.

    What's the syntax for "concatenate"?

    I can query the table to pull all resources from a group.... But, then when I do a "Foreach" statement... How do I concatenate the string?

    Thanks,
    Lowell


  • 6.  RE: GEL: Email to Group

    Posted Jan 14, 2011 03:23 PM
    I think THIS thread was discussing similar things in the past.... (but I think some of the links & code in that thread are corrupted now? Bad boards!)

    Simple answer though is; do the concatenation in the SQL (assuming your SQL is stronger than your GEL?)


  • 7.  RE: GEL: Email to Group

    Posted Jan 14, 2011 05:26 PM
    Hi Dave,
    I was asking what the "concatenate" flag in GEL script is. I can concatenate in C, C#, VB, Perl, but none of these seem to be recognized by GEL.

    & && || ........

    Thanks,
    Lowell


  • 8.  RE: GEL: Email to Group

    Posted Jan 14, 2011 05:30 PM
    ^ no I realised that, just saying that you could do it in the SQL instead; problem solved!

    Not at my work PC right now and I can't recall offhand how I did in in GEL.... think you can just "set" the variable to itsself with the extra string added on the end.... I'll post some real code on Monday if thats not enough of a clue.


  • 9.  RE: GEL: Email to Group

    Posted Jan 14, 2011 05:53 PM
    Hi Dave, Thanks so much. There doesn't seem to be any good reference guides for syntax questions. Normally, I'd just go down to the bookstore and find the syntax.

    Just to let you know, I created a GEL and Stored Procedure, to import timesheet values from an external systems and XOG the timesheet values into Clarity timesheets.

    This code, I have a GEL XOG in OBS nodes and grant a set of rights... 8.1.3 has a defect that only allows 20 Global Rights to be XOGged in at one time. My goal is to get this code to Email a "Group" so, that I can change the recipients of the notification without recompiling the GEL every time

    thanks,
    Lowell


  • 10.  RE: GEL: Email to Group

    Posted Jan 15, 2011 03:38 AM
    GEL is really jelly which is built on top of java so its the java syntax you want. Also worth looking at is jexl as this is the expression language used by jelly.

    Try this:

    <j:set var="myVariable" value="Initial value..." />

    To append another variable:
    <j:set var="myVariable" value="${myVariable + anotherVariable}" />

    or to append plain text:
    <j:set var="myVariable" value="${myVariable} plain text string" />


  • 11.  RE: GEL: Email to Group

    Posted Jan 15, 2011 06:03 AM

    mark wrote:

    <j:set var="myVariable" value="${myVariable + anotherVariable}" />
    OK thats what I was getting at with my rather ineloquant "you can just set the variable to itsself with the extra string added on the end" :grin:

    Thanks Mark!

    --

    For a list of email addresses that you are going to use in GEL:EMAIL then the list is delimited by a semi-colon - and don't get any spaces in there either.


  • 12.  RE: GEL: Email to Group
    Best Answer

    Posted Nov 28, 2011 06:25 PM
    Hi Dave and Mark,
    Here's the code I came up with. It's not the prettiest code.


    <!--Email Group Variables:-->
    <gel:parameter default="TRG Resource Administrator" var="EMAILGROUP"/>
    <core:set value="0" var="emailCount"/>
    <!--Email Group Variables:-->





    <!--e_group used to loop through group specified in EMAILGROUP and create email with all addresses-->
    <sql:query var="e_group">
    SELECT u.email_address
    FROM CMN_CAPTIONS_NLS NLS,
    cmn_sec_users u,
    CMN_SEC_GROUPS G,
    cmn_sec_user_groups UG,
    CMN_LOOKUPS L,



    srm_resources r
    WHERE NLS.TABLE_NAME = 'CMN_SEC_GROUPS'
    AND NLS.PK_ID = G.ID
    AND NLS.LANGUAGE_CODE = 'en'
    AND u.id = ug.user_id
    AND

    u.id = r.user_id
    AND G.GROUP_TYPE_ID = L.ID
    and g.id = ug.group_id
    AND L.LOOKUP_TYPE = 'SEC_GROUP_TYPE'
    AND

    g.is_active = '1'
    AND

    r.is_active = '1'
    AND NLS.name = '${EMAILGROUP}'
    </sql:query>
    <!--count_e_group used to count active members of group specified in EMAILGROUP and create email with all addresses-->
    <sql:query var="count_e_group">
    SELECT count(*) as num
    FROM CMN_CAPTIONS_NLS NLS,
    cmn_sec_users u,
    CMN_SEC_GROUPS G,
    cmn_sec_user_groups UG,
    CMN_LOOKUPS L,



    srm_resources r
    WHERE NLS.TABLE_NAME = 'CMN_SEC_GROUPS'
    AND NLS.PK_ID = G.ID
    AND NLS.LANGUAGE_CODE = 'en'
    AND u.id = ug.user_id
    AND

    u.id = r.user_id
    AND G.GROUP_TYPE_ID = L.ID
    and g.id = ug.group_id
    AND L.LOOKUP_TYPE = 'SEC_GROUP_TYPE'
    AND

    g.is_active = '1'
    AND

    r.is_active = '1'
    AND NLS.name = '${EMAILGROUP}'
    </sql:query>

    <!--Loop through e_group (note 3 tests: >0 >1 =0 -->
    <core:if test="${count_e_group.rows[0].num == 1}">
    <core:set value="${e_group.rows[0].email_address}" var="email_addr"/>
    </core:if>

    <core:if test="${count_e_group.rows[0].num > 1}">
    <!--Write first record-->
    <core:set value="${e_group.rows[0].email_address}" var="email_addr"/>
    <!--Write each subsequent record with a semi colon-->

    <core:forEach begin="1" items="${e_group.rows}" trim="true" var="email_row">



    <core:set value="${email_addr};${email_row.email_address}" var="email_addr"/>

    </core:forEach>


    </core:if>

    <core:if test="${count_e_group.rows[0].num == 0}">

    <core:set value="Clarity@regence.com" var="email_addr"/>
    </core:if>