Arcade Code Help!!

1002
6
07-16-2020 04:19 PM
VarunSehgal1
New Contributor II

Hi Sir, can you help me with appending of data from related layer to the main layer with arcade code.
I have two data one is the Inspection Points and other is the attachment layer both. The attachment layer is related to the Inspection points. So for eg in one Inspection point there may be 5 or 4 attachment points.
I just wan to get the attachment data into the Inspection points based on the global id. I am trying my best.

I have a gdb and in the calculate field I am adding the expression:

var tbl = FeatureSetByName($datastore,"Attachment_Collection");
var codigo = $feature["GlobalID"];
var sql = "GlobalID = '" + codigo + "'";
Console(sql);
var mantenimientos = Filter(tbl, sql);
var cnt = Count(mantenimientos);
var historia = "";
if (cnt > 0) {
historia = cnt + " Mantenimiento(s):";
for (var mantenimiento in mantenimientos) {
var txt_fecha = Text(mantenimiento.Feature_Height);
var txt_man = txt_fecha + mantenimiento.Attachment_Type;
historia += TextFormatting.NewLine + txt_man;
}
} else {
historia = "No hay mantenimientos";
}

return historia;

It will be a pleasure to hear from you.

Thanks in advance

0 Kudos
6 Replies
XanderBakker
Esri Esteemed Contributor

Hi Varun Sehgal ,

I notice that you are using an example Arcade expression that I published in the past using an example of fire hydrant maintenance history. If you have a relationshipclass between the two layers, you can use the function "FeatureSetByRelationshipName" to access directly the related records. You will need the exact name of the relationship te be able to use this. You can use the GlobalID and a filter, but the syntaxis of the sql will be different. 

In the loop you construct a multi line text combining feature height and attachment type. Is that what you want?

VarunSehgal1
New Contributor II

Thank You  Xander Bakker so much for you valuable response!!
Yes I want that to display in my attribute table so that I can extract them as csv. 
Right now we have them in POPUP.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Varun Sehgal ,

Sorry for the delay and thanks for the additional explanation. I assume that you used an Arcade expression to show this in the pop-up? If so, the same expression can be used in the field calculation (even in ArcGIS Online), since you are accessing the data using the datastore. How you tried that?

0 Kudos
VarunSehgal1
New Contributor II

Hi Xander Bakker Thanks for the reply

 The popup code was build by some other code. I really donot know how he did it. can you please help with this as I want to export this in attribute table so that I can export and get the data.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Varun Sehgal ,

Would it be possible to have access to a subset of the data? This will make it easier to see how the two are related and if the FeatureSetByRelationshipName function is something that you can use in your case. 

VarunSehgal1
New Contributor II

Hi Xander Bakker‌ 
Thank you for the help but I have written the code on the basis of code in the pop up expression.
Thank You very much for the help!!

0 Kudos