Docmerge displaying if and else tags

Hiya, 

I am creating a docmerge template with a lot of if/else conditions using || for or and && for and conditions in it. I am testing in sections and have noticed that the if/else isnt working and the if and else tags are being left in the rendered document. Is there something wrong in the coding i have set up? or is this a bug? Screenshot below of the codeing on the left and result on the left.

  • Hi Ross, there are a couple of syntax issues in your example. If you fix these, it might resolve the weird behavior you're seeing:

    1. {else if} should actually be {elseif} with no space.
    2. The proper formatting for && and || is as follows:
      1. {if cladding_c == "Rendered" || cladding_c == "Plastered"} (and likewise for the other condition with || in your example)

    As a side note, you should also only use straight quotes, not "smart quotes" that some word processors use. It appears that you are using straight quotes in your example, but I thought I'd mention it just in case!

    If you make those changes, does that clear up the unexpected output?

    -Brenda

  • Well that is annoying. i should have known that!!!! ill give them a go and let you know the outcome!

  • I have updated the text and now get a different issue. I have pasted the text below to check formatting. I am now getting Error: Unexpected token '||'. I have another DocMerge issue as well but ill post a new question.

    {#surv_survey_quotes_1}

    {if cladding_c == "Ship Lap" || "Vertical Tile" || "Rendered" || "Plastered"}The property has a {cladding_c} finish on the external façade. The cladding was in {lbl_cladding_condition_c} at the time of the survey. {endif}

    {if cladding_c == "Rendered" || "Plastered"}Due to the nature of the external cladding on the property, there is a possible risk of damage due to core drilling.{elseif cladding_c == "Shiplap" || "Vertical Tile"} Due to the nature of the external cladding on the property, CUSTOMER may require a section to be removed local to the external termination prior to commencing the installation work. We would ask that you arrange to have the cladding removed prior to our visit and then re-instated around the external termination following the completion of the installation work.{endif}

    {if extra_drilling_c == "Yes"}Due to the construction of the property, there may be an additional cost for extra drilling as itemised below. This additional cost will only be charged where relevant and will be based on the extra time taken to complete the drilling. {endif}

    {/surv_survey_quotes_1}

  • Actually, my other issue is still relevent to this thread. same behavior, more simple as there are no elseif

    I have updated the formatting per the original answer. I have pasted an extract below as well as screenshot of the issue. 

    ***NOTE: Please ignore the fact the field names have lbl in them, im not accidentaly using the label reference***

    {#surv_survey_quotes_1}

    {if is_there_a_loft_c == "Yes" && lbl_loft_hatch_c == "No"}We were unable to gain access to the loft, due to there being no loft hatch.{endif}

    {if is_there_a_loft_c == "Yes" && lbl_loft_hatch_c == "No" && lbl_loft_accessed_c == "No"}We were unable to gain access to the loft during the time of the survey. {endif}

    {if is_there_a_loft_c == "Yes" && lbl_loft_hatch_c == "No" && lbl_loft_accessed_c == "No" && lbl_lost_space_c == "Yes"}During our survey it was noted that the loft is boarded. We may need to remove some of the boards in order to complete our installation and our quotation includes an additional hour of labour to cover these works.{endif}

    {if lbl_small_hatch_c == "Yes"}The loft hatch was not of sufficient size to enable us to carry out our proposals. We ask that you arrange for a larger opening to be provided. This opening needs to be at least 450mm by 500mm.{endif}

    {if lbl_airtight_loft_c == "Yes" && lbl_must_smell_c == "No"}There was very little air movement in the loft space. To ensure the optimum performance of the positive input ventilation system we would recommend cross-flow ventilation within the loft space. We recommend a qualified roofing contractor completes this work.{endif}

    {if lbl_airtight_loft_c == "No" && lbl_must_smell_c == "Yes"}There was a musty smell within the loft space. This could be because of a lack of cross- flow ventilation and we would recommend that a qualified roofing contractor investigates this. Good ventilation in the loft is essential to protect the roof trusses.{endif}

    {/surv_survey_quotes_1}

  • Hey Ross, it looks like the formatting for the use of || is still off. Here is what it is currently vs the correct format:

     Current:  

    {if cladding_c == "Ship Lap" || "Vertical Tile" || "Rendered" || "Plastered"}

     Corrected:

    {if cladding_c == "Ship Lap" || cladding_c == "Vertical Tile" || cladding_c == "Rendered" || cladding_c == "Plastered"}

    The difference is that you can't join multiple things with a || after the equals sign. Each A == B condition is standalone, which basically just means you have to repeat cladding_c == [value] a lot - once for each value you want to check.

    You will need to make the same change for the || statements in the second paragraph. I also see "CUSTOMER" in all caps in the second paragraph - is that intended to be a variable possibly? It could also be capitalized for emphasis, in which case please disregard me. Smiley

    -Brenda

  • Please see previous GIF.........

    the customer is to anonymise the customer it is for.

    Thanks for the quick response, i think i need to go to sleep!

  • Hey Brenda,

    im getting the same error after the corrections. Would we be able to hop on a meet to go through it together or with someone from the team if possible?

  • That is strange, I have tested the same conditionals using stock fields and it works as expected. I also don't see any known issues around this, but maybe you are the lucky one to discover a possible issue. Slight smile Would you mind filing a case with Support so they can help you look into it further? You can share a link to this thread to give them some of the context.

    If you and Support end up figuring out the issue, it would be nice if you could come back here and let us know the verdict too, if you don't mind.

    Thank you and sorry I wasn't able to get it figured out!

  • This syntax seems okay to me, and I also can't find any known issues around this behavior you're seeing where the conditional text ("if", "endif") appears in the merged document. We might be missing something, but I would also ask Support about this and see if there's further troubleshooting to be done.

    If you find out what the cause is, let us know so we can all learn. Slight smile

    Thanks and good luck!

    -Brenda

  • Hi Brenda, i think i have found more information on this issue. It seems to be if you use pipes on the same field options, like i am above. i have another file using pipes but the condition uses a different field and works fine. i will raise a support ticket.

    Example

    {if lbl_flued_appliance_c == "Yes" || lbl_wood_burner_c == "Yes"}We will not install an extract fan in the same room as an open flued appliance or a wood burner. Mechanical ventilation provision in other areas may require a gas spillage test.{if lbl_flued_appliance_c == "Yes" || lbl_wood_burner_c == "No"}We will not install an extract fan in the same room as an open flued appliance. Mechanical ventilation provision in other areas may require a gas spillage test.