Is there an order in which Arrtibute Rules work?

252
5
Jump to solution
a week ago
AbiDhakal
Occasional Contributor III

- I have this expression that calculates years and populates a field called 'Age'. It gets this information to calculate years from a field called EstbYear (as you can see in the expression below) that I populate with the year it was established. However, it puts the years in the 'Age' field only after the layer is checked and unchecked in the web map. With this happening, another field calculation that relies on 'Age' is not getting calculated unless I go back in and put the age manually first, before I put in the other variables for the calculation to happen

This is the calculation I used which is working just fine:

var currentTime = Year(Now());
var survey = $feature["EstbYear"];

// Calculate age in years
var age = 0;
if (!IsEmpty(survey)) {
age = currentTime - survey;
}

return age;

Is there something I am missing. Do I have to tell somewhere that the next calculation needs to double check the 'Age' field so it can calculate the next field. Do I need to put something in the arcade rule in ArcGIS Pro for the calculation to recognize 'Age' field to so it can see the 'Age' field value to do the next calculation?

Thank you for your help,
Abi

0 Kudos
2 Solutions

Accepted Solutions
Jake_S
by
Occasional Contributor II

Hey @AbiDhakal, I wanted to see this in real time so I created some data in a PostGres enterprise geodatabase in ArcGIS Pro 3.2 and added two attribute rules.

One like yours getting the Age of the feature based on EstbYear field value (used your exact rule) then had a second rule fire based on the Age. If the Age was over 10 return 'OLD' else return 'NEW' to a text field called nextfieldcalc.

 

if($feature.Age > 10){
    return "OLD"
}
return "NEW"

 


I then published as a referenced data feature service to my internal 11.2 Enterprise environment.

I created a map and then used that map in Experience Builder (EB). Not relevant as I can repro in both a Web Map or EB.

When editing in ArcGIS Pro the rules work fine (video below).



When editing in EB the rules work as you described. The first rule triggers the second does NOT unless some other update has been done. (video below).


To answer your question, you should not have to do anything. The rules fire in order of operation.

In the past version of server there was a parameter called supportsReturnServiceEditsOption that there was an issue with publishing services where the setting was set to FALSE for some reason which prevented edits from refreshing the service view in both environments.

I'm not sure what the case is here. But know you are not in the wrong, this is reproduceable. 

~Jake

View solution in original post

AbiDhakal
Occasional Contributor III

@Jake_S  - Thank you for your diligent approach. I appreciate you taking the trouble to troubleshoot for me. Like you mention I changed the order of operation in the attribute rule and it now seems to work. I made, Order 1 to calculate Age' from the EstbYear field and then I made Order 2 to calculate the next field that succeeds that. That was really helpful.

Thank you again,
Abi

View solution in original post

0 Kudos
5 Replies
Jake_S
by
Occasional Contributor II

Hey @AbiDhakal, I wanted to see this in real time so I created some data in a PostGres enterprise geodatabase in ArcGIS Pro 3.2 and added two attribute rules.

One like yours getting the Age of the feature based on EstbYear field value (used your exact rule) then had a second rule fire based on the Age. If the Age was over 10 return 'OLD' else return 'NEW' to a text field called nextfieldcalc.

 

if($feature.Age > 10){
    return "OLD"
}
return "NEW"

 


I then published as a referenced data feature service to my internal 11.2 Enterprise environment.

I created a map and then used that map in Experience Builder (EB). Not relevant as I can repro in both a Web Map or EB.

When editing in ArcGIS Pro the rules work fine (video below).



When editing in EB the rules work as you described. The first rule triggers the second does NOT unless some other update has been done. (video below).


To answer your question, you should not have to do anything. The rules fire in order of operation.

In the past version of server there was a parameter called supportsReturnServiceEditsOption that there was an issue with publishing services where the setting was set to FALSE for some reason which prevented edits from refreshing the service view in both environments.

I'm not sure what the case is here. But know you are not in the wrong, this is reproduceable. 

~Jake

AbiDhakal
Occasional Contributor III

@Jake_S  - Thank you for your diligent approach. I appreciate you taking the trouble to troubleshoot for me. Like you mention I changed the order of operation in the attribute rule and it now seems to work. I made, Order 1 to calculate Age' from the EstbYear field and then I made Order 2 to calculate the next field that succeeds that. That was really helpful.

Thank you again,
Abi

0 Kudos
Jake_S
by
Occasional Contributor II

@AbiDhakal Can you confirm that both fields are populated at the same time in a Web Map? 

I was under the impression you we not seeing this happen in your current configuration.

~Jake

0 Kudos
AbiDhakal
Occasional Contributor III

@Jake_S  -  here is my email address. abi.dhakal@forestry.alabama.gov.

Would it be possible for you to email me, please.

I will be leaving in the next 20 minutes for the day, but you can email me within the 20 minutes or, tomorrow which ever suites you the best and we can go from there. I can send you a Zoom invite so you can see what I'm doing.

Thank you for your great help.
Abi

0 Kudos
AbiDhakal
Occasional Contributor III

@Jake_S- Good morning, Jake.

This is what happens. I go in to make a polygon in the Web AppBuilder - I'm not using Experience Builder right now as it does not have the edit widget adequately functioning - and as I double click to finish making the polygon a table opens up for me to enter the attribute values. I begin by entering the EstbYear and other information that is relevant to the next calculation and once I do that, close the attribute table and go to the layer widget to uncheck and check back the layer in question as this refreshes the layer both the 'Age' and the other 'field' get populated , which is what I wanted.

However, before your helpful hints that was not happening the 'Age' would get populated but the next calculation would not until I went back to the 'Age' field and re-added the age again.

With your helpful hints, I went to the Attribute Rules window in ArcGIS Pro and reordered the 'Age' field to get populated first before the next calculation and that did it.

Hope this helps, Jake. Please let me know if you need further explanation or, you need to connect with me to see it. I will be glad to show you my process.

Thank you,
Abi

0 Kudos