Clarity

  • 1.  Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 03:35 AM
    Hello,

    ( sorry if it is too long ).
    I would like to create a process which sends an email to all managers belonging to different OBS units in IT Department containing the list of resources who have not completed their timesheet + the related time periods.

    First, I wrote a query to select all the managers that I needed and the result is stored in var= "result3".
    Then I wrote this:
    <core:forEach items="${result3.rowsByIndex}" trim="true" var="mng">
     <core:set value="${mng[0]}" var="userid"/> 
    <core:set value="${mng[1]}" var="ManagerLastName"/>
     <core:set value="${mng[2]}" var="ManagerFirstName"/>
     <core:set value="${mng[3]}" var="ManagerEmail"/>
     <core:set value="${mng[4]}" var="idManager"/>
     <gel:log> manager ${mng[1]} </gel:log>
    Next I selected all the resources who did not compile their timesheet and the result is stored in result2.
    and this is the last part:
    <core:forEach items="${result2.rowsByIndex}" trim="true" var="tms">
     <core:set value="${tms[0]}" var="id_risorse"/>
     <core:set value="${tms[1]}" var="Full_Name"/>
     <core:set value="${tms[2]}" var="Email"/>
     <core:set value="${tms[3]}" var="Time_Period"/>
     <core:set value="${tms[4]}" var="Prid"/>
     <core:set value="${tms[5]}" var="MANAGER_ID"/>
    
     <gel:log> Risorsa: ${tms[1]} periodo: "${tms[3]}"</gel:log> 
    
    <gel:email from="clarity@mediobanca.it"
     subject="MISSING TIMESHEET: ${tms[3]}"
     to="${mng[3]}">
    
     ( Here is the CONTENT OF EMAIL: Here is the list of resources who .......
     Resource: ${tms[1]}, id= "${tms[0]}"
    
     </gel:email> 
    
    </core:forEach> 
    </core:forEach> 
    </core:forEach> 
    </gel:script>
    Here, the problem is that in this way, each manager receives lots of email related to each resource or each time period, while each manager must receive ONLY 1 email containing the LIST OF RESOURCES ..

    I tried also putting the last two </core:forEach> that are in line 20 ,21 after <gel:log.. and before <gel:email.... (put them in line 10) , in this way each manager receives ONLY 1 email, but the problem is that now Resource: ${tms[1]}, refer to the last resource only.
    I do not know how can I refer to the list of resources inside <gel:email....

    I do appreciate if someone knows if it is possible to refer to the list of resources inside gel:email? if yes, how? or is it possible to write loop inside gel:email ?

    Any answer or idea is highly appreciated.

    Manhy thanks,
    Mona


  • 2.  RE: Send an email containing the list of items or array in Gel script
    Best Answer

    Posted May 16, 2013 04:18 AM
    You need to loop (loop 1) around your first query (managers);

    Start to build the email.

    Loop (loop 2) around your second query (resources)
    Add details to the email
    Next "loop 2" record.

    Send the email

    Next "loop 1" record.


  • 3.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 05:42 AM
    Dear Dave;

    Thanks a lot for your useful answer. I did as you wrote and it worked.
    But would you please kindly tell me how can I insert space for each resource inside email?

    I mean for example , I would like the content of email to be like this:

    Resource "A" in "period1",
    Resource "A" in "period2",

    Resource "B" in "period1",
    Resource "B" in "period3",

    ......

    what I see now is : Resource "A" in "period1", Resource "A" in "period2",Resource "B" in "period1", Resource "B" in "period3",......

    Thanks again for your help,

    Best,
    Mona


  • 4.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 06:09 AM
    I'm not sure how you are adding the "text" to your email - when I do it in the GEL script "in-line" in a CDATA block - rather than via GEL variables (which is how you appear to be doing it?) - then I just don't any problems with line-breaks (since I am adding it line-by-line - this is a bit hard to explain without example code though; I'll see if I can find a thread with some in!).

    The actual formatting of the email itself (e.g. line breaks, spaces etc) - depends on your Clarity version... v13+ formats the email with html type notation so you can include that sort of mark-up programmatically - pre v13 (v7/8/12) you could add in manual line breaks with a control character - see here how to use newline while concating data in foreach - and actually that thread has an example of formatting the email "line by line" also (see mark's reply in that thread).


  • 5.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 06:50 AM
    Thanks a lot Dave,

    I read the Thread and the link. Unfortunately, since I am a beginner in Gel script, I got a bit confused.

    I use Clarity 13.1.0 . I tried using this character &#xA; but did not work.

    Also I tried what Mark said in that thread (I think I did as he said), but not worked. Maybe , I did not write correctly.

    Here is the summery of my code:

    query1 to get the managers
    Loop1

    start build email --> <gel:email from="xxxx"

    subject="MISSING TIMESHEET}"

    to="${mng[3]}">

    then second query (to get the resources who did not compile timesheet)
    Loop2 till the end is as below:
    <core:forEach items="${result2.rowsByIndex}" trim="true" var="tms">
    
                <core:set value="${tms[0]}" var="id_risorse"/>
    
    
            <core:set value="${tms[1]}" var="Full_Name"/>
    
    
            <core:set value="${tms[2]}" var="Email"/>
    
    
            <core:set value="${tms[3]}" var="Time_Period"/>
    
    
            <core:set value="${tms[4]}" var="Prid"/>
    
    
            <core:set value="${tms[5]}" var="MANAGER_ID"/>
    
    
    
    
     <gel:log> Risorsa: ${tms[1]} periodo: "${tms[3]}"</gel:log>
    
      Risorsa: ${tms[1]},   period: ${tms[3]}
    
    
    
    
    
    </core:forEach>  
    
        </core:forEach> 
    
    
    
    To access the timesheet in clarity follow this link:
    
    ${EntryURL}/niku/nu#action:timeadmin.timesheetBrowserReturn
    
    
    
    </gel:email> 
    I hope I could clarify my problem.

    Thanks in advance,

    Best
    Mona


  • 6.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 06:59 AM
    ( &#xA; was for pre v13 - you should be able to use html markup now)

    But your loop initially looks OK to me (and you are adding your text to the email line-by-line OK) - I'm not sure I understand what output you are getting (in the email) though. :unsure:


  • 7.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 07:09 AM
    thanks Dave,

    The output in the log is OK and each reosurce is in 1 line, but in email This is the output:

    Resource1 , time period1 Resource1 , time period2 Resource1 , timeperiod3 Resource2, timeperiod 1, .........

    While I would like to get this:

    Resource1 timeperiod1
    Resource1 , time period2
    .....
    ....


    Many thanks,
    Mona


  • 8.  RE: Send an email containing the list of items or array in Gel script

    Posted May 16, 2013 07:30 AM
    So have your tried the html line break;

    <br>


  • 9.  RE: Send an email containing the list of items or array in Gel script

    Posted May 17, 2013 04:19 AM
    Thanks a lot Dave,

    It worked with <br> :)

    Best,
    Mona