General Discussion

  • 1.  FreeMarker: show image from a section template within repeatable section.

    Adopter
    Posted 11-17-2024 11:40
    Edited by Alicia Rico 11-17-2024 13:08

    Hello,

    I'm totally new to freemarker and I have been struggling with the code bellow. I always get an error saying  "[in template "body template for Document 'null' (null)"] ...-- Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value ... - Failed at: #assign secFotos = ... [in template "body template for Document 'null' (null)."

    The image section can be visible or not, depending on the status of the equipment, Q05Q01.

    The image question is optional, so it can contain an answer or not, Q21QCK07.

    Any idea what am I doing wrong on the image part? After <#if value != "Not Operational">. The previous part works fine.

    Thanks a lot!

    <div class="page-break"></div>
    <div class="page">
    <div class="content"> 
    <#list 1..10 as num> <!--1 lista contador-->
        <#assign NumUnit = "U" + num?string("000") />
    <#if answers.NumT[0] != "0"> <!--2 -->
    <#list dataRecord.pages.PageXXXs.sections.SectionXXXs.rows as row> <!--3-->
          <#list row.pages.XXXs.sections.SecXXXs.answers.Unit.values as valueX> <!--4-->
    <#if valueX == NumUnit> <!--5 unidad igual contador-->
    <#if row.pages.XXXs.sections.SecQ05.instances[0].answers.Q05Q01?has_content> <!--6 IF ESTADO-->
                <#list row.pages.XXXs.sections.SecQ05.instances[0].answers.Q05Q01.values as value> <!--7-->
      
    <#if value != "Not Operational"><!--8 if not operational secFotos is not visible-->
     <#assign secFotos = row.XXXs.SecFotos.instances[0].answers.Q21QCK07 />
    <#if secFotos.values?size > 0>
    <!-- Display the image -->
    <div>
    <img src="data:${secFotos.values[0].contentType};base64,${secFotos.values[0].bytes}" alt="${secFotos.values[0].filename}" />
    </div>
    </#if>                   
    <#else><!--8-->                      
    </#if><!--8-->
    </#list><!--7-->
                      
    <div class="page-break"></div>  
    <div class="page">
    <div class="content"> 
                      
    </#if><!--6-->
    </#if><!--5-->
    </div></div>                      
    </#list><!--4-->
    </#list><!--3-->
    </#if> <!--2-->
    </#list> <!--1 lista contador--> 
    </div></div>     


    ------------------------------
    Alicia Rico
    CI
    Johnson Controls
    ------------------------------



  • 2.  RE: FreeMarker: show image from a section template within repeatable section.

    Adopter
    Posted 11-18-2024 14:31

    Try changing 

    <#assign secFotos = row.XXXs.SecFotos.instances[0].answers.Q21QCK07 />

    to

    <#assign secFotos = row.XXXs.SecFotos.instances[0].answers.Q21QCK07!"" />

    Seems like that object is missing when it tries to assign it.



    ------------------------------
    Calvin Hunter
    Project Manager
    Vipond Inc
    calvin.hunter@vipond.ca
    ------------------------------



  • 3.  RE: FreeMarker: show image from a section template within repeatable section.

    Adopter
    Posted 11-19-2024 10:17
    Edited by Alicia Rico 11-20-2024 02:54

    Thanks a lot Calvin!

     

    And also Thanks! for the note on macros you published some time ago.



Reminder: Content posted to our Community is public content.  Please be careful not to post Intellectual Property that you do not have permission to share.  For more information please refer to our Terms Of Use