<?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: Attribute rule to change one attribute value in one field based on a domain value in another field. in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103846#M46223</link>
    <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#domain" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/arcade/function-reference/data_functions/#domain&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not too sure what you're trying to do. Could you give us an example?&lt;/P&gt;&lt;P&gt;Here are a few things I noticed:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fc = $feature // you can just call Domain($feature, ...) below.
var POC_fieldname = 'PointOfContact'
var Contact_fieldname = 'ContactInformation'

var PLdom_values = Domain(fc, POC_fieldname)
var PCdom_values = Domain(fc, Contact_fieldname)

var PL_codedVals = PLdom_values.codedValues
var PC_codedVals = PCdom_values.codedValues

// You're looping through both domains, so it will return the first
// entry of PLdom_values that corresponds to an entry in PCdom_values
// I think you want to get the PCdom_value that corresponds to the $feature's
// PLdom_value. That means only looping through PCdom_values!

// Domain.codedValues is an array of dictionaries:
// [ {"code": 1, "name": "Description"} ]

// As I said, not too sure what you want, but I guess it's more in the line of this:

var POC_description = DomainName($feature, POC_fieldname)
for(var PC in PC_codedVals) {
  if(PC.name = POC_description) {
    return PC.code
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Oct 2021 06:26:34 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-10-01T06:26:34Z</dc:date>
    <item>
      <title>Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103623#M46201</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;So I am trying to update one value in one field based on a selected value in another field using domains and attribute rules. So far I am struggling to figure out how to set up the attribute rule where the user selects one value from one domain which in turn automatically updates a value in another field based on matching coded values. Here is what I have so far:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var fc = $feature
var POC_fieldname = 'PointOfContact'
var Contact_fieldname = 'ContactInformation'

var PLdom_values = Domain(fc, POC_fieldname)
var PCdom_values = Domain(fc, Contact_fieldname)

var PL_codedVals = PLdom_values.codedValues
var PC_codedVals = PCdom_values.codedValues

for (var PL in PL_codedVals){
for (var PC in PC_codedVals){

if (PL == PC){
return PC
}
}
}&lt;/LI-CODE&gt;&lt;P&gt;I haven't done anything like this in arcade, but I do it all the time in python. I am struggling a bit with this so any help on this would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:08:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103623#M46201</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-09-30T17:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103846#M46223</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#domain" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/arcade/function-reference/data_functions/#domain&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not too sure what you're trying to do. Could you give us an example?&lt;/P&gt;&lt;P&gt;Here are a few things I noticed:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fc = $feature // you can just call Domain($feature, ...) below.
var POC_fieldname = 'PointOfContact'
var Contact_fieldname = 'ContactInformation'

var PLdom_values = Domain(fc, POC_fieldname)
var PCdom_values = Domain(fc, Contact_fieldname)

var PL_codedVals = PLdom_values.codedValues
var PC_codedVals = PCdom_values.codedValues

// You're looping through both domains, so it will return the first
// entry of PLdom_values that corresponds to an entry in PCdom_values
// I think you want to get the PCdom_value that corresponds to the $feature's
// PLdom_value. That means only looping through PCdom_values!

// Domain.codedValues is an array of dictionaries:
// [ {"code": 1, "name": "Description"} ]

// As I said, not too sure what you want, but I guess it's more in the line of this:

var POC_description = DomainName($feature, POC_fieldname)
for(var PC in PC_codedVals) {
  if(PC.name = POC_description) {
    return PC.code
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 06:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103846#M46223</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-10-01T06:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103890#M46229</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Here is what I am trying to accomplish.&lt;/P&gt;&lt;P&gt;When the end user selects a code from one domain, loop through another domain and select the matching code, and return the value. I don't know if I explained this enough but if needed, I can provide screenshots if that may help.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 11:04:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103890#M46229</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-10-01T11:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103898#M46230</link>
      <description>&lt;LI-CODE lang="javascript"&gt;var output_domain = Domain($feature, "OutputField")// domain on the output field
var input_domain_code = $feature.InputField
var input_domain_description = DomainName($feature, "InputField", input_domain_code)

// if the codes of your domains are the same
return input_domain_code

// if the descriptions (what you see in the table) are the same
for(var od in output_domain.codedValues) {
  if(input_domain_description == od.name) {
    return od.code
  }
}
return null //no matching description found

// if you need some custom mapping (eg an output_domain code corresponds
// to multiple input_domain codes), you can use a dictionary
// {input_domain_code: output_domain_code}
var domain_code_dict = {
  1: 3,
  2: 1,
  3: 1,
  4: 2,
  5: 1
}
return domain_code_dict[input_domain_code]&lt;/LI-CODE&gt;&lt;P&gt;If none of these fit your needs, then I need screenshots.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 11:36:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1103898#M46230</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-10-01T11:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1105302#M46413</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I was looking for:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var input_domain_code = $feature.InputField
// if the codes of your domains are the same
return input_domain_code&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 06 Oct 2021 19:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1105302#M46413</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2021-10-06T19:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change one attribute value in one field based on a domain value in another field.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1164564#M54063</link>
      <description>&lt;P&gt;I am grateful for the information in this post, but I am having trouble using the below part of the expression with the variable definitions as shown just above it. In my case the descriptions match in both fields, but one is a text field and the other an integer. The integer field is the subtype field, too, by the way.&lt;/P&gt;&lt;P&gt;var output_domain = Domain($feature, "Patrol")// domain on the output field&lt;BR /&gt;var input_domain_code = $feature.PatrolCode&lt;BR /&gt;var input_domain_description = DomainName($feature, "PatrolCode", input_domain_code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for(var od in output_domain.codedValues) {
  if(input_domain_description == od.name) {
    return od.code
  }
}
return null //no matching description found&lt;/PRE&gt;&lt;P&gt;the trouble is that when I click the Verify button, it tells me&amp;nbsp;&lt;BR /&gt;Invalid expression.&lt;BR /&gt;Error on line 6.&lt;BR /&gt;Dictionary type expected&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Line 6 in the error message is the one shown as line 2 above. How can I correct the error, please?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;BR /&gt;&lt;/SPAN&gt;Justin&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 20:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-one-attribute-value-in/m-p/1164564#M54063</guid>
      <dc:creator>JustinKraemer</dc:creator>
      <dc:date>2022-04-14T20:20:39Z</dc:date>
    </item>
  </channel>
</rss>

