<?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 Arcade expression for returning optional fields in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347356#M55744</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I need a bit of help with an arcade expression and optional fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a survey 123 where people can submit a name/contact information (phone AND/OR email), or choose not to and stay anonymous. I want to set up the expression to return either&lt;/P&gt;&lt;P&gt;1) a phone number&lt;BR /&gt;2) an email&lt;BR /&gt;3) both a phone number and an email&lt;BR /&gt;4) neither&amp;nbsp;&lt;/P&gt;&lt;P&gt;While I can write IIF statements to find if the field is empty or not, I am not sure how to write statements that will return one or another, both, or neither. Has anyone done something like this before and been  able to provide guidance?&lt;/P&gt;&lt;P&gt;Here is a simple flow chart to help get an idea of returns and show some potential outputs.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Drawing6.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85403i6321E72ACCE84455/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Drawing6.png" alt="Drawing6.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2023 20:04:06 GMT</pubDate>
    <dc:creator>leahmaps</dc:creator>
    <dc:date>2023-11-08T20:04:06Z</dc:date>
    <item>
      <title>Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347356#M55744</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I need a bit of help with an arcade expression and optional fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a survey 123 where people can submit a name/contact information (phone AND/OR email), or choose not to and stay anonymous. I want to set up the expression to return either&lt;/P&gt;&lt;P&gt;1) a phone number&lt;BR /&gt;2) an email&lt;BR /&gt;3) both a phone number and an email&lt;BR /&gt;4) neither&amp;nbsp;&lt;/P&gt;&lt;P&gt;While I can write IIF statements to find if the field is empty or not, I am not sure how to write statements that will return one or another, both, or neither. Has anyone done something like this before and been  able to provide guidance?&lt;/P&gt;&lt;P&gt;Here is a simple flow chart to help get an idea of returns and show some potential outputs.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Drawing6.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85403i6321E72ACCE84455/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Drawing6.png" alt="Drawing6.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 20:04:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347356#M55744</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-08T20:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347408#M55746</link>
      <description>&lt;P&gt;Here's one way to do it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var name;// = 'Jane Doe';
var phone;// = '999-999-9999'
var email;// = 'Joe@email.com';

if (IsEmpty(name)) name = 'Anonymous';
if (IsEmpty(phone)){ 
  iif(IsEmpty(email), `${name}, no contact information provided`, `${name}: ${email}`)
} else {
  iif(IsEmpty(email), `${name}: ${phone}`, `${name}: ${phone}, ${email}`)
}                &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 20:57:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347408#M55746</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-08T20:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347413#M55747</link>
      <description>&lt;P&gt;Worked! Here is what I did with the dynamic content/name so that if nothing was provided it returned anonymous&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var name = IIf(IsEmpty($feature.full_name) == True, 'Anonymous', $feature.full_name);
var phone= $feature.phone_number;
var email = $feature.email;


if (IsEmpty(phone)){ 
  iif(IsEmpty(email), `${name}, no contact information provided`, `${name}: ${email}`)
} else {
  iif(IsEmpty(email), `${name}: ${phone}`, `${name}: ${phone}, ${email}`)
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:01:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347413#M55747</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-08T21:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347415#M55748</link>
      <description>&lt;P&gt;I had made a subsequent edit to my script after posting which takes care of the empty name. In your case, you can just use&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var name = IIf(IsEmpty($feature.full_name), 'Anonymous', $feature.full_name);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347415#M55748</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-08T21:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347417#M55749</link>
      <description>&lt;P&gt;Cool, two ways to do it. This is much more of an intense script than I can write. If I may ask, what is the purpose of the&lt;STRONG&gt;&amp;nbsp;`&amp;nbsp;&lt;/STRONG&gt;in the script? It is not acting as a quotation mark but make it so they are not necessary for text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:04:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347417#M55749</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-08T21:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347423#M55750</link>
      <description>&lt;P&gt;That's a &lt;A href="https://developers.arcgis.com/arcade/guide/template-literals/" target="_self"&gt;template literal&lt;/A&gt;. It allows you to embed expressions.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;`${name}: ${email}` //with template literals
name + ': ' + email //using regular quotes&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347423#M55750</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-08T21:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression for returning optional fields</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347425#M55751</link>
      <description>&lt;P&gt;You are awsome! Thanks much for your help&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:11:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-for-returning-optional-fields/m-p/1347425#M55751</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-08T21:11:48Z</dc:date>
    </item>
  </channel>
</rss>

