<?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: Create validation with multiple If statements in Sweet in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418689#M56671</link>
    <description>&lt;P&gt;That's brilliant thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 03 May 2024 13:36:27 GMT</pubDate>
    <dc:creator>RosieLaura</dc:creator>
    <dc:date>2024-05-03T13:36:27Z</dc:date>
    <item>
      <title>Create validation with multiple If statements in Sweet</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418589#M56667</link>
      <description>&lt;P&gt;Hi asking this on S123 board as there isn't a board set up for Sweet that I can find.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set up validation for when I draw a line feature in Sweet, I can apply the following validation to the width field. The line feature is a field boundary and the width field is filled in by the surveyor in the form on sweet manually. The width must be a multiple of 50cm and between 100cm and 500cm. I have written two statements that work individually but not at the same time and need some help combining them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// STATEMENT 1: validate width is in multiples of 0.5 - Check that numerical value is divisible by a number&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var value = $feature["margin_width"];&lt;BR /&gt;var multipleOf = 50&lt;/P&gt;&lt;P&gt;if (value != null &amp;amp;&amp;amp; value % multipleOf != 0 ) {&lt;BR /&gt;var msg = `Value ${value} is not multiple of ${multipleOf}`;&lt;BR /&gt;return msg;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return true;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// STATEMENT 2: validate width is between 1 and 5m&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var Width = $feature["margin_width"];&lt;BR /&gt;if (Width &amp;lt; 0 || Width &amp;gt; 600) {&lt;BR /&gt;var msg = `Margin width ${Width} is not between 0 and 5m `;&lt;BR /&gt;return msg;&lt;BR /&gt;}&lt;BR /&gt;return true;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 10:56:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418589#M56667</guid>
      <dc:creator>RosieLaura</dc:creator>
      <dc:date>2024-05-03T10:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create validation with multiple If statements in Sweet</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418595#M56668</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/573975"&gt;@RosieLaura&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you give this a try and let me know if it helps out?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var marginWidth = $feature["margin_width"];
var multipleOf = 0.5;

if ((marginWidth &amp;gt;= 1 &amp;amp;&amp;amp; marginWidth &amp;lt;= 5) &amp;amp;&amp;amp; (marginWidth % multipleOf !== 0)) {
    return `Margin width ${marginWidth} is not a multiple of ${multipleOf} and not between 1 and 5m.`;
} else if (marginWidth &amp;lt; 1 || marginWidth &amp;gt; 5) {
    return `Margin width ${marginWidth} is not between 1 and 5m.`;
} else if (marginWidth % multipleOf !== 0) {
    return `Margin width ${marginWidth} is not a multiple of ${multipleOf}.`;
}

return true;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Hope that helps!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 11:31:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418595#M56668</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-05-03T11:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create validation with multiple If statements in Sweet</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418618#M56669</link>
      <description>&lt;P&gt;HI Cody, Thanks for getting back so quickly!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It throws an error for an unexpected =&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RosieLaura_0-1714737244055.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/102974i67380094BBEA7AF1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RosieLaura_0-1714737244055.png" alt="RosieLaura_0-1714737244055.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;RosieLaura_0-1714737244055.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 11:54:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418618#M56669</guid>
      <dc:creator>RosieLaura</dc:creator>
      <dc:date>2024-05-03T11:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create validation with multiple If statements in Sweet</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418677#M56670</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/573975"&gt;@RosieLaura&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had mistakenly implemented the modulus function inside of the if statement, taking some Javascript and putting it in Arcade had broken it, my bad!&lt;/P&gt;&lt;P&gt;Here is an adjusted function:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var marginWidth = $feature["margin_width"];
var multipleOf = 0.5;

var isMultiple = (marginWidth % multipleOf == 0);
var isInRange = (marginWidth &amp;gt;= 1 &amp;amp;&amp;amp; marginWidth &amp;lt;= 5);

if (isInRange &amp;amp;&amp;amp; !isMultiple) {
    return "Margin width " + marginWidth + " is not a multiple of " + multipleOf + " and not between 1 and 5m.";
} else if (!isInRange) {
    return "Margin width " + marginWidth + " is not between 1 and 5m.";
} else if (!isMultiple) {
    return "Margin width " + marginWidth + " is not a multiple of " + multipleOf + ".";
}

return true;&lt;/LI-CODE&gt;&lt;P&gt;Hopefully this will get you going!&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 13:05:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418677#M56670</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2024-05-03T13:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create validation with multiple If statements in Sweet</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418689#M56671</link>
      <description>&lt;P&gt;That's brilliant thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 13:36:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/create-validation-with-multiple-if-statements-in/m-p/1418689#M56671</guid>
      <dc:creator>RosieLaura</dc:creator>
      <dc:date>2024-05-03T13:36:27Z</dc:date>
    </item>
  </channel>
</rss>

