Select to view content in your preferred language

Using Arcade to auto-populate an attribute field based on previous attribute field answer in Field Maps

281
6
4 weeks ago
CraigCrowe
New Contributor II

I have an Attribute field "Compliance" where if any of these Domain values ("Other", "Education", "Caution" or "Infringement") are selected , then the following Attribute field "Compliant" with Domain values ("Yes" or "No") should auto-populate the "No" value, using an Arcade expression. Can someone please help me out with the expression, as I've tried numerous different iterations of the script and just can't get it to work.

Disclaimer: this form has already been in use and has thousands of entries already captured. The "Compliant" field will be a new Attribute field to help with reporting. It was created way back before ArcGIS Pro was widely used, and before "Field Maps Designer" was a twinkle in the developers eyes!

Tags (2)
0 Kudos
6 Replies
RhettZufelt
MVP Notable Contributor

This will do that:

var field = $feature.Compliance   // set Compliance value to variable

var arr = ["Other", "Education", "Caution", "Infringement"]  //  List to compare to

if (Includes(arr,field)){       // If in the list, return "NO"
  return "No"
}

R_

0 Kudos
CraigCrowe
New Contributor II

Hi Rhett. That worked! Thank you!

The problem I have now is that I have the 'Compliant' field's 'Default value' set as "Yes", and hoping it would change when selecting one of the above Domain options, the problem is the Default value isn't showing (see attached screenshot), so now I have to also figure out the script for when it isn't these options selected. Can you help with that please?

And as with ESRI, once one thing is sorted, a couple of other things become broken. The Default as mentioned, and with the 'Compliance' field I have the 'Include "No value" option' unticked, but it shows up in the form. I guess this is for another post.

0 Kudos
RhettZufelt
MVP Notable Contributor

Not sure about the No Value option, doesn't seem like it should be showing, but it does.

Default values can be set/changed in the Template tab of the Form editor in Field Maps Designer:

RhettZufelt_0-1715697255671.png

However, since you are 'either' entering a Yes or No (no other values), you can handle that with the form calculated expression.

I've modified it to check to see if the value is Empty, if so, or if it matches any values in the list, it will return "No", otherwise, will return "Yes".

var field = $feature.Compliance   // set Compliance value to variable

var arr = ["Other", "Education", "Caution", "Infringement"]  //  List to compare to

if (Includes(arr,field) || IsEmpty(field)){       // If in the list, return "No"
  return "No"                                     // or is Empty
}else{
  return "Yes"                                    // else return "Yes"
}

R_

 

0 Kudos
CraigCrowe
New Contributor II

Hi Rhett,

So, I tried this solution, but as I cannot remove the "No value" option from the "Compliance" field, I will need to have the script take that into account, not it being empty, so if the value is "No value", then "Compliant" field is populated as "Yes". I really appreciate your time, if you could give me an idea how this would look, but in the meantime, I'll try to figure it out myself.

UPDATE - There is something going wrong with the settings from Field Maps Designer flowing through to Field Maps. I still have the "No value" option ticked off in the "Compliance" field, but it does show up as default in Field Maps, and it also straight away populates the "Compliant" field with "No", where it should be "Yes", as I haven't entered any of the specified values that should trigger the "No" value. (see attached screenshot)

I really need this option to work, as we have other forms that will require the same functionality.

I may have to create a Support item with ESRI, but they have been no help in the past, so that is why I came to this forum, and you've been more help than any previous interaction with sorting out an issue. In that I appreciate your time.

0 Kudos
RhettZufelt
MVP Notable Contributor

If you un-check the "Include No value option" in Field Maps designer, that will just keep "No value" from being one of the available options in the pick list (if checked, "No value" will show at the top of the pick list and let you choose it when you select that field).

The "No Value" in your image just says that there is no value assigned to that field yet (no default value set for it). However, if you click on that field, "No value" should not be one of the options to choose from unless you check the box for that field.

As far as the "Compliant" field being populated with "No", that normally means that "No" is the default value, otherwise, it should say "No value" like above.  Just clear the default value for that field in the form should do it.

R_

0 Kudos
CraigCrowe
New Contributor II

Thanks again Rhett. As you can see in the screenshot, "Yes" has been set as the default value, but I had to do this in ArcMap Templates, as it says I didn't have permissions to edit Templates in Form editor in Field Maps Designer, probably because our data isn't hosted.

I'll try your new expression now.

0 Kudos