General Discussion

 View Only
  • 1.  CSV Template with Repeatable Section

    Adopter
    Posted 7 days ago

    Hello,

    I'm creating a csv template that includes a repeatable section with a condition.

    It works fine, except that, for those rows where the condition is not met, it also add a blank line (with ;;;) in the csv.

    Basically the code is:

    COLUMN1;COLUMN2;COLUMN3
    {{#each dataRecord.pages.P.sections.S.rows}}
    {{#pf:if pages.SP.sections.SS.answers.Q1.values.[0] ">" "0"}}
    {{#with pages.SP.sections.SS.answers}
    {{Q1.values.[0]}};
    {{Q2.values.[0]}};
    {{Q3.values.[0]}};
    {{/with}}{{/pf:if}}
    {{/each}}

    But all in 3 rows to get the correct line breaks:

    COLUMN1;COLUMN2;COLUMN3
    {{#each dataRecord.pages.P.sections.S.rows}}{{#pf:if pages.SP.sections.SS.answers.Q1.values.[0] ">" "0"}}{{#with pages.SP.sections.SS.answers}{{Q1.values.[0]}};{{Q2.values.[0]}};{{Q3.values.[0]}};{{/with}}{{/pf:if}}
    {{/each}}

    I have also round it with 

    {{#pf:outputFormat "DOCUMENTFORMAT"}}...{{/pf:outputFormat}}

    But TrueContext shuts down when trying to open the csv after submission.

    Also tried | instead of ;

    Any idea on how  to avoid this blank line?

    Thanks a lot

    #Repeatable Sections

    #CSV Template



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


  • 2.  RE: CSV Template with Repeatable Section

    Posted 6 days ago

    Hello Alicia,

    I just used your example and I am not seeing the blank line that you are seeing. I did tweak the template a little bit to the following (replaced the ; to a , and put your 3 value references on the same line. 

    COLUMN1,COLUMN2,COLUMN3
    {{#each dataRecord.pages.P.sections.S.rows}}
    {{#pf:if pages.SP.sections.SS.answers.Q1.values.[0] ">" "0"}}
    {{#with pages.SP.sections.SS.answers}}
    {{Q1.values.[0]}},{{Q2.values.[0]}},{{Q3.values.[0]}}
    {{/with}}{{/pf:if}}
    {{/each}}

    My Form submission looks like this and the final CSV output, we would expect to see only 2 rows.

    My final CSV looks like:

    COLUMN1,COLUMN2,COLUMN3
    1,1,1
    2,2,2
    Something else that I noticed in the template that you pasted above is a missing } on this line: {{#with pages.SP.sections.SS.answers}. It produced an error for me until I corrected the missing }.

    Let me know if this was helpful or if you are still seeing that blank line. 


    ------------------------------
    Ian Chamberlain
    Solutions Architect
    TrueContext
    ------------------------------



  • 3.  RE: CSV Template with Repeatable Section

    Adopter
    Posted 6 days ago

    Hello Ian,

    thanks for testing. Very helpful.

    I've moved these 3 together {{/with}}{{/pf:if}}{{/each}}. If I open the csv with exel, it looks perfect. 

    But, if I open it with note pad I see (as per your example):

    COLUMN1,COLUMN2,COLUMN3,,
    1,1,1,,
    2,2,2
    Which means, it adds the "blank line" after the previous one, instead of bellow.
    I'll test if this is good enough when importing the content to another system.
    About the missing }, it was me copying it in this post.
    Again, many thanks.


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



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