Is it possible to use two item fields in one conditional?

Hi,

I would like to use two fields of the item (Conference) that I'm iterating over in one conditional statement for e.g.

      <w:if condition="start_date != end_date">
      .... write start and end date of conference ....
      </w:if>     

      <w:if condition="start_date = end_date">
      .... write only end date of conference ....
      </w:if>

All the examples that I've seen only use one field inside the condition, I've tried using start_date and end_date as above but it does not go inside the if statement.

Kind regards,

Dot

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Michael Slater

    Dot,

    The challenge here is that the right-hand-side of these conditions cannot be a WebvantaScript value like this; it is expected to be a constant.

    There is a workaround, though: you can define a variable with the the end_date, and then use it in the expression. For more on variables, see this article:

    http://helpdesk.webvanta.com/entries/363586-webvantascript-now-has-variables-and-pseudo-nesting

    The code you need is something like this:

    <w:var name="end_date_var"><w:end_date /></w:var>

    <w:if condition="start_date != {{end_date_var}}">

  • 0
    Avatar
    Michael Slater

    Dot,

    The challenge here is that the right-hand-side of these conditions cannot be a WebvantaScript value like this; it is expected to be a constant.

    There is a workaround, though: you can define a variable with the the end_date, and then use it in the expression. For more on variables, see this article:

    http://helpdesk.webvanta.com/entries/363586-webvantascript-now-has-variables-and-pseudo-nesting

    The code you need is something like this:

    <w:var name="end_date_var"><w:end_date /></w:var>

    <w:if condition="start_date != {{end_date_var}}">

  • 0
    Avatar
    Dorothy Cadle

    Thank you Michael. The final version of the code now looks as follows and it works like a charm:

    <w:var name="start_date_var"><w:start_date /></w:var>

    <w:var name="end_date_var"><w:end_date /></w:var>

    <w:if condition="{{start_date_var}} != {{end_date_var}}">

  • 0
    Avatar
    Michael Slater

    Great, glad it is working for you.

    It doesn't hurt, but FYI, you shouldn't need to put the start date into a variable -- the left side of the condition can be as you had it before.

Please sign in to leave a comment.
Powered by Zendesk