<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using IF statements to create a conditional constraint message in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285241#M49029</link>
    <description>&lt;P&gt;I did a bit of testing, and as far as I can tell it seems like the constraint_message column in the XLS form doesn't recognize conditional logic.&lt;/P&gt;&lt;P&gt;However, there are a couple ways you could achieve this. First off, I put this in the &lt;EM&gt;constraint&lt;/EM&gt; column (these conditions must return TRUE for the entry to be valid)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;${cab_year} = 9999 or (${cab_year} &amp;lt;= number(format-date(today(), '%Y')) and ${cab_year} &amp;gt; 1000)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then, in the &lt;EM&gt;constraint_message&lt;/EM&gt; column, you could just have a more general error message.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"Please make sure you have entered the year in the correct format (YYYY) and it is not greater than the current year."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, you could have note fields with &lt;EM&gt;null&lt;/EM&gt; in the &lt;EM&gt;bind::esri:fieldType&lt;/EM&gt; column that conditionally display if a certain condition is met. So something like this:&lt;/P&gt;&lt;P&gt;In the &lt;EM&gt;label&lt;/EM&gt;:&amp;nbsp;&lt;STRONG&gt;&amp;lt;font color = 'red'&amp;gt;Year input cannot be greater than current year with the exception of 9999.&amp;lt;/font&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the relevant column:&amp;nbsp;&lt;STRONG&gt;${cab_year} &amp;gt; number(format-date(today(), '%Y'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And then you'd add another note field the exact same way, but with a different label and condition in the relevant column.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 16:06:51 GMT</pubDate>
    <dc:creator>Katie_Clark</dc:creator>
    <dc:date>2023-05-03T16:06:51Z</dc:date>
    <item>
      <title>Using IF statements to create a conditional constraint message</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285107#M49024</link>
      <description>&lt;P&gt;I want to create a conditional constraint message for a Survey123 Connect question.&amp;nbsp; The user is asked to input an installation year.&amp;nbsp; If the year doesn't match a 4 digit format or is greater than the current year, the user should get one of the following two messages:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Please enter a valid year format, YYYY.&amp;nbsp; For example, 2023.&lt;/LI&gt;&lt;LI&gt;Year input cannot be greater than the current year with the exception of 9999.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The expression I have tried within the constraint message column is as follows:&lt;/P&gt;&lt;P&gt;if(${cab_year} = 9999, '',&lt;BR /&gt;if(regex(${cab_year}, '^[1-9][0-9]{3}$') and ${cab_year} &amp;lt;= number(format-date(today(), '%Y')),&lt;BR /&gt;'', 'Year input cannot be greater than current year with the exception of 9999.')) +&lt;BR /&gt;if(regex(${cab_year}, '^[1-9][0-9]{3}$'), '', 'Please enter a valid year format, YYYY. For example, 2023.')&lt;/P&gt;&lt;P&gt;When I go to input any value that should kick out a constraint message, I don't get the particular message, I get the entire constraint message field.&amp;nbsp; See below image.&lt;/P&gt;&lt;P&gt;I'm new to Survey123 Connect and not sure if this is possible to begin with.&amp;nbsp; Also, there very well could be something wrong with my expression which is also something I'm learning.&amp;nbsp; Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cab Year Constraint Message.PNG" style="width: 494px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69733i7F4344AFEA9007BE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cab Year Constraint Message.PNG" alt="Cab Year Constraint Message.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 12:23:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285107#M49024</guid>
      <dc:creator>Bec</dc:creator>
      <dc:date>2023-05-03T12:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using IF statements to create a conditional constraint message</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285241#M49029</link>
      <description>&lt;P&gt;I did a bit of testing, and as far as I can tell it seems like the constraint_message column in the XLS form doesn't recognize conditional logic.&lt;/P&gt;&lt;P&gt;However, there are a couple ways you could achieve this. First off, I put this in the &lt;EM&gt;constraint&lt;/EM&gt; column (these conditions must return TRUE for the entry to be valid)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;${cab_year} = 9999 or (${cab_year} &amp;lt;= number(format-date(today(), '%Y')) and ${cab_year} &amp;gt; 1000)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then, in the &lt;EM&gt;constraint_message&lt;/EM&gt; column, you could just have a more general error message.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"Please make sure you have entered the year in the correct format (YYYY) and it is not greater than the current year."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, you could have note fields with &lt;EM&gt;null&lt;/EM&gt; in the &lt;EM&gt;bind::esri:fieldType&lt;/EM&gt; column that conditionally display if a certain condition is met. So something like this:&lt;/P&gt;&lt;P&gt;In the &lt;EM&gt;label&lt;/EM&gt;:&amp;nbsp;&lt;STRONG&gt;&amp;lt;font color = 'red'&amp;gt;Year input cannot be greater than current year with the exception of 9999.&amp;lt;/font&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the relevant column:&amp;nbsp;&lt;STRONG&gt;${cab_year} &amp;gt; number(format-date(today(), '%Y'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And then you'd add another note field the exact same way, but with a different label and condition in the relevant column.&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 16:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285241#M49029</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2023-05-03T16:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using IF statements to create a conditional constraint message</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285280#M49031</link>
      <description>&lt;P&gt;Below is how I have my constraint currently set up:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;(${cab_year} = 9999) or (regex(${cab_year}, '^[1-9][0-9]{3}$') and ${cab_year} &amp;lt;= number(format-date(today(), '%Y')))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This constraint works for what I intended.&amp;nbsp; I was just hoping in the constraint message I could use IF statements to apply conditional constraint messages based upon the user input.&amp;nbsp; It looks like from your reply that is not possible.&amp;nbsp; So my constraint message is set to display as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Enter a 4-digit year in the format YYYY. Year input cannot be greater than current year with the exception of 9999.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Which it still gets out what I needed to the user if they input an incorrect value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I definitely appreciate your input and will play around with the other options you suggested.&amp;nbsp; It's all a learning experience for me!&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 16:59:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-if-statements-to-create-a-conditional/m-p/1285280#M49031</guid>
      <dc:creator>Bec</dc:creator>
      <dc:date>2023-05-03T16:59:42Z</dc:date>
    </item>
  </channel>
</rss>

