Skip to main content

Search

Document Generation Loops and Design

Comments

1 comment

  • Christof Nussbaumer

    Hi Fernando Alves

     

    1 - To check if an option is selected in a multichoice field you can use count of indexOf function on the field's result.
    And to avoid an error if no option is selected (empty result) you have to additionally check against null first.

    In combination the If Condition in your document template should look like this:

     

    [[if [[FlavourType]] !=null && [[FlavourType]].indexOf("Peanut Butter")>=0]]...[[end if]]

     

     

    2 - The lines works the wysiwyg way: each line break you have in document template will be rendered in generated document - except the linke breaks inside negative If Conditions for sure and this is the point: Place the line breaks inside the conditions.

    In your case it works best with line breaks in front of texts and move the whole block one line up to prevent an unwanted space on top (note the places of paragraph marks).

     

    Your choice: [[FlavourType]]

    The recipes for ice-creams are:[[if [[FlavourType]] !=null && [[FlavourType]].indexOf("Peanut Butter")>=0]]

    The recipe for Peanut Butter is Peanut and Butter and loads of sugar.[[end if]][[if [[FlavourType]] !=null && [[FlavourType]].indexOf("Vanilla")>=0]]

    The recipe for Vanilla is Vanilla and milk and cream and loads of sugar.[[end if]][[if [[FlavourType]] !=null && [[FlavourType]].indexOf("Vodka Orange")>=0]]

    The recipe for Vodka Orange is vodka, orange juice and loads of sugar.[[end if]]

    Enjoy your ice-cream

     

    Results:

    0

Please sign in to leave a comment.