Can attribute rules reference other features in the GDB?

321
9
06-26-2019 01:05 PM
Highlighted
by
Occasional Contributor III

I would like to update a feature based on the values from another table.  Can I reference other tables using attribute rules and arcade.  'FeatureSets' seems to only refer to referencing other layers in AGOL/Portal.

Thanks!

Xander Bakker‌ ?

Reply
0 Kudos
9 Replies
Highlighted
Esri Esteemed Contributor

Hi T L ,

Interesting question. I don't have much experience with Attribute Rules, but the global variable $datastore is supported in Attribute Rules. However, what I understand from what you posted, you have a table in an Enterprise geodatabase that you want to reference and that doesn't seem to work. Is that correct?

Reply
0 Kudos
Highlighted
by
Occasional Contributor III

I have a view and I want to update a feature table based on the views changes.  

Using arcade and attribute rules you can updated fields based on other fields values, I want to updated another tables field based on a fields value. (in an EGDB)

Seems like I need the equivalent to 'FeatureSets' but in a GDB and not AGO/Portal.

Its doesn't seem to work because I don't know if you can or how to do it.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi TLongSUGF ,

If you are not able to locate the table or view using the $datastore, I guess it is not possible. Maybe it is best to create a support case and see if they can confirm this and if so, create an idea to include this in a future version. I'm sorry that I can't be more helpful, since I don't have an environment to reproduce this specific use case.

Reply
0 Kudos
Highlighted
by
Occasional Contributor III
Looks like I can access other features but I cant get this to work.

I am trying update one field (SEEDED) based on another field (seeded_mulched) using the parentrowid and uniquerowid.

My target points to the Feature class SEEDED field based on the sql expression.

Any suggestions?

var fc = FeatureSetByName($datastore,'SUDOE.DBO.s123_pandareclam',['SEEDED']);
var t_parent = $feature.parentrowid;
var sql = "uniquerowid = '" + t_parent + "'";
var target = First(Filter(fc, sql));

var t_seed = $feature.seeded_mulched
if ((t_seed) == "Satisfactory")
{
target = "PASS";
}

After enabling the trigger as an attribute rule. When I change seeded_mulched to "Satisfactory", it reverts back to null.
Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi T L ,

Good to hear that you have access to other features. When I look at the expression, there are a couple of comments that I can think of (but keep in mind that I don't really have experience with Attribute Rules):

  • When you retrieve the other featureset you may need to include the field you want to query on (with filter). So include the field uniquerowid in the list of fields (not sure if this is really necessary, but that would make sense to me)
  • When you want to write a value you have to return the value at the end of the expression. 
  • Looking at the expression, it seems that you want to write to a different feature than the current feature. Is that correct? I don't think it works like this (although I am not sure with attribute rules). I would try at set the expression on the other table (SUDOE.DBO.s123_pandareclam) and query the featureset that you have defined the expression on and change values of the records
Reply
0 Kudos
Highlighted
by
Occasional Contributor III

Instead of doing a static field calculate in order to symbolize my data by the related features I am trying to updated the parent as the related records are edited using attribute rules.  

Any suggestions?

var sql = "VALVE_ID = '" + $feature.valveid + "'"
var guid = "'" + TOP(filter(FeatureSetByName($datastore,'UTILITIES.DBO.uti_wdSystemValve',['globalid']),sql),1) + "'";
var date_ = $feature.exercisedate
return {
'edit': [{
'className': 'UTILITIES.DBO.uti_wdSystemValve',
'updates': [{
'GLOBALID': guid,
'attributes': {
'lastexercised': date_
}
}]
}]
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

HiT L , 

When you do a TOP of 1 record, you still have a collection although it has only 1 records. Maybe do a first (this will return the record) and explicitly consult the globalid from that record.

Something like this on line 2:

"'" + First(TOP(filter(FeatureSetByName($datastore,'UTILITIES.DBO.uti_wdSystemValve',['globalid']),sql),1))['globalid'] + "'";

I also haven't seen this type of return value (object) that you are returning. Does that work?

Reply
0 Kudos
Highlighted
by
Occasional Contributor III

I am trying to return just the globalid of the top record as set the globalID as the variable.  It works when I hard code a globalid.

The below works, but it obviously does not use the variables.

var valves = FeatureSetbyName($datastore, "UTILITIES.DBO.uti_wdSystemValve",['globalid'])
var valve = first(filter(valves, "VALVE_ID = '" + $feature.valveid + "'"))

var date_ = $feature.exercisedate
return {
'edit': [{
'className': 'UTILITIES.DBO.uti_wdSystemValve',
'updates': [{
'globalID': '{DE10ED35-B0A6-4E0B-86E7-0012405029F8}',
'attributes': {
'lastexercised': date_
}
}]
}]
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi T L ,

If you try the expression below, what does it return to the console?

var valves = FeatureSetbyName($datastore, "UTILITIES.DBO.uti_wdSystemValve",['globalid'])
var valve = first(filter(valves, "VALVE_ID = '" + $feature.valveid + "'"))
var globaltext = "'{" + valve["globalID"] + "}'";
Console(globaltext);

var date_ = $feature.exercisedate
return {
'edit': [{
'className': 'UTILITIES.DBO.uti_wdSystemValve',
'updates': [{
'globalID': globaltext,
'attributes': {
'lastexercised': date_
}
}]
}]
}
Reply
0 Kudos