Clarity

  • 1.  [Q] Help with HTML Gel Email

    Posted Feb 21, 2017 10:02 AM

    Hello All, I am having some trouble with my HTML email. I can't seem to get this to display the contents of the table. I have tried this a few ways, the header is building but not the contents. 

     

              <gel:email from="${sender}" to="${me}" subject="${subject}">
                   <![CDATA[
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD/>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
    ]]>
    <![CDATA[<P ALIGN="left"><B>]]>Dear Project Manager(s),<![CDATA[</B></P>]]>
    <![CDATA[<P ALIGN="left">]]>${messageText1}<![CDATA[</P>]]>

         <sql:query escapeText="0" var="prj">
              <![CDATA[
         SELECT pm.full_name
         , P.NAME
         , P.code
         FROM prteam tm
         join inv_investments P on tm.prprojectid=tm.prprojectid
         JOIN inv_projects inv ON P.ID=inv.prid
         JOIN srm_resources pm on p.manager_id=pm.user_id
         WHERE P.is_active = 1
         AND inv.is_template = 0
         and p.is_open_for_te = 1
         AND pm.is_active = 1
         AND P.manager_id IN (5011208, 5011571, 5011925, 5011933, 5034026, 5039001)
         AND tm.prresourceid=5011623
         AND tm.prisopen = 1
         group by pm.full_name
         , P.NAME
         , P.code
         ORDER BY pm.FULL_name
         ]]>

         </sql:query>
         
    <![CDATA[
    <TABLE ALIGN="left" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
    <TR ALIGN="left" VALIGN="middle">
         <TH>]]>
    Project Manager<![CDATA[</TH>
         <TH>]]>
    Project ID<![CDATA[</TH>
         <TH>]]>
    Project Name<![CDATA[</TH>
    </TR>]]>
         
                   <core:forEach items="${prj.rows}" var="row">
                        <core:set var="proj_manager" value="${row.proj_manager}"/>
                        <core:set var="proj_id" value="${row.proj_id}"/>
                        <core:set var="proj_name" value="${row.proj_name}"/>               
                        <!-- Project Manager: ${full_name}, Project ID: ${proj_id} , Project Name: ${proj_name} -->

    <![CDATA[
    <TR ALIGN="left" VALIGN="middle">
         <TD>]]>
    ${proj_manager}<![CDATA[</TD>
         <TD>]]>
    ${proj_id}<![CDATA[</TD>
         <TD>]]>
    ${proj_name}<![CDATA[</TD>
    </TR>
    </TABLE>]]>

                   </core:forEach>
    <![CDATA[
    </BODY>
    </HTML>
    ]]>

              </gel:email>

    Or this way

              <gel:email from="${sender}" subject="${subject}" to="${me}">

    &lt;P ALIGN="left"&gt;&lt;B&gt;
    Dear Project Manager(s),&lt;/B&gt;&lt;/P&gt;
    &lt;P ALIGN="left"&gt;${messageText1}&lt;/P&gt;
    &lt;/br&gt;&lt;/br&gt;

              <sql:query escapeText="0" var="prj">
         SELECT pm.full_name
         , P.NAME
         , P.code
         FROM prteam tm
         join inv_investments P on tm.prprojectid=tm.prprojectid
         JOIN inv_projects inv ON P.ID=inv.prid
         JOIN srm_resources pm on p.manager_id=pm.user_id
         WHERE P.is_active = 1
         AND inv.is_template = 0
         and p.is_open_for_te = 1
         AND pm.is_active = 1
         AND P.manager_id IN (5011208, 5011571, 5011925, 5011933, 5034026, 5039001)
         AND tm.prresourceid=5011623
         AND tm.prisopen = 1
         group by pm.full_name
         , P.NAME
         , P.code
         ORDER BY pm.FULL_name
         </sql:query>
         
    &lt;TABLE ALIGN="left" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="100%"&gt;
    &lt;TR ALIGN="left" VALIGN="middle"&gt;
    &lt;TH&gt;Project Manager&lt;/TH&gt;
    &lt;TH&gt;Project ID&lt;/TH&gt;
    &lt;TH&gt;Project Name&lt;/TH&gt;
    &lt;/TR&gt;
                   <core:forEach trim="true" items="${prj.rows}" var="row">
                        <core:set var="proj_manager" value="${row.proj_manager}"/>
                        <core:set var="proj_id" value="${row.proj_id}"/>
                        <core:set var="proj_name" value="${row.proj_name}"/>               
                        <!-- Project Manager: ${full_name}, Project ID: ${proj_id} , Project Name: ${proj_name} -->
              

    &lt;TR ALIGN="left" VALIGN="middle"&gt;
    &lt;TD&gt;${proj_manager}&lt;/TD&gt;
    &lt;TD&gt;${proj_id}&lt;/TD&gt;
    &lt;TD&gt;${proj_name}&lt;/TD&gt;
    &lt;/TR&gt;

                   </core:forEach>
    &lt;/TABLE&gt;
    &lt;/br&gt;&lt;/br&gt;
    &lt;/br&gt;&lt;/br&gt;

              </gel:email>

     

    Both of these display this way. 

     

    Email

    I am not sure what i am doing wrong on these. Any help would be greatly appreciated. 

     

    Keri



  • 2.  Re: [Q] Help with HTML Gel Email

    Posted Feb 21, 2017 12:58 PM

    Your query is returning only the columns named full_name, name, and code.

     

    You are trying to reference values proj_manager, proj_id, and proj_name.

     

    You may be missing some aliases in your select columns of the query, or you may want to check the row.<fieldalias> access names so they are consistent.

     

    You may also want to double check that your query is actually returning results too.

     

    From the look of it, I don't think the issues are with the style/method that the HTML is being built with (escaped vs. CDATA blocks).



  • 3.  Re: [Q] Help with HTML Gel Email
    Best Answer

    Posted Feb 21, 2017 01:35 PM

    Hello Nick, Yes, I caught that right after I put the question up. Yikes!. I have been trying to figure out the next issue. 

    Seems like its only populating the first row correctly... but not the rest. 

    email2

     

    Thanks

     

    Edit: Found the issue... 

    I had the /table tag before the /forEach

    BEFORE:

     

    <![CDATA[
    <TR ALIGN="left" VALIGN="middle">
    <TD>]]>
    ${proj_manager}<![CDATA[</TD>
    <TD>]]>
    ${proj_id}<![CDATA[</TD>
    <TD>]]>
    ${proj_name}<![CDATA[</TD>
    </TR>
    </TABLE>]]>

    </core:forEach>
    <![CDATA[</TABLE>
    </BODY>
    </HTML>
    ]]>

    FIXED: 

    <![CDATA[
    <TR ALIGN="left" VALIGN="middle">
    <TD>]]>
    ${proj_manager}<![CDATA[</TD>
    <TD>]]>
    ${proj_id}<![CDATA[</TD>
    <TD>]]>
    ${proj_name}<![CDATA[</TD>
    </TR>]]>

    </core:forEach>
    <![CDATA[</TABLE>
    </BODY>
    </HTML>
    ]]>