|
BLOG
|
Hi Marcelo Rosensaft , There is a way to do this, but it would use 5 (simple) expressions and HTML. You could use something like this in the pop-up: <a href="{expression/expr0}" style="display:{expression/expr1}">{expression/expr2}</a><div style="display:{expression/expr3}">{expression/expr4}</div> It consists of an anchor (html link) and a div element. Both can be provided with a display style setting that is either "none" (do not show) or "block" (show). Additionally you will have expressions that will contain the url, the explaining url text and the normal text. {expression/expr0} - Will return the URL when it is available or return an empty string {expression/expr1} - The expression to validate if the url should be shown IIf(should display url, "block", "none"); {expression/expr2} - the link text if the url is available o an empty string {expression/expr3} - expression to validate if the url should be shown (inverting true/false arguments) IIf(should display url, "none", "block"); {expression/expr4} - The normal text to display if the url is not available Example when a link is available: Example when no link is available
... View more
08-07-2020
12:55 PM
|
0
|
0
|
19008
|
|
POST
|
Hi David Krady , When you configure an Arcade expression for a pop-up that should appear when clicking on a feature, you do not have access the actual location where the user clicked. You will only have the clicked feature geometry and not the exact location. (I hope this will be provided at some point in the future). In your case the expression contains a loop and you use the return inside the loop. When the sequence hits the return, it will exit the arcade expression. So, you will only have the first feature (attribute) it found in the process. To return multiple features, you will need to use a variable that you populate with the results and return that variable after the loop. Have a look at the example below: var intersectLayer = Intersects(FeatureSetByName($map, "Deer Management Zones"), $feature);
var cnt = Count(intersectLayer);
var result = "DMZ(s) found:"
// first check if you have any intersecting features
if (cnt > 0) {
for (var f in intersectLayer){
result += TextFormatting.NewLine + " - " + f.DMZ;
}
} else {
result = "no DMZs found..."
}
return result;
... View more
08-07-2020
12:08 PM
|
0
|
0
|
5805
|
|
POST
|
Hi T L , Glad to hear that it works. My comment taking the first record is that at this moment the expression will only take the first abandoned pipe and updates it for each contract or invoice. If you need all the related pipes to be updated you shouldn't take the first and loop through the results and add all globalid of the features that need to be updated. Edit: one additional comment. For efficiency purposes you may want to query only the GlobalID field on line 12 and not all the fields.
... View more
08-06-2020
12:40 PM
|
0
|
0
|
9897
|
|
POST
|
Hi TLongSUGF , I think it will be very difficult to provide working code without access to the data, but have a look at the code below. I changed some variable name to make it a bit more understandable for me. Some observations: I removed some redundant declarations from the start of the expression On row 5 and 6 I simplified the SQL In the loop that starts on line 12, "contract" is a feature/row and to access the attribute you have to use the name of the field (edit that on line 14) I have places the modification of the update array inside a validation of the pipe count When accessing a field by its name that contains underscores in the name, it might be better to use "$feature["Field_Name"] than $feature.Field_Name. This might not be an issue anymore, but is was some time ago. var updates = [];
var counter = 0;
var contract_fc = FeatureSetByName($datastore,"SUDOECMS.DBO.doe_EAP_pipelineabandon_contracts", ["contract"], false);
var rowid = $feature.uniquerowid;
var sql = "parentrowid = @rowid";
var contracts = Filter(contract_fc, sql);
var cnt = count(contracts);
//var array = ["AM-094", "AM-095"]
if (cnt > 0) {
for(var contract in contracts) {
var abandonedpipes = FeatureSetByName($datastore,"SUDOECMS.DBO.doe_EAP_pipelineabandon", ["*"], false);
var invoice_id = contract["NameOfFieldWithInvoiceID"]; // edit this!
var sql2 = "invoice = @invoice_id";
var pipes = Filter(abandonedpipes, sql2);
if (Count(pipes)>0) {
var pipe = first(pipes); // why only the first???
updates[counter] = {'globalID': pipe.GlobalID,
'attributes': {
'q_1': $feature.status,
'q_1comments': $feature["q_xcomments"],
'q_1rank': $feature["q_xrank"]}
}
counter++;
}
}
return {'result': $feature["q_x"],
'edit': [{'className': 'SUDOECMS.DBO.doe_EAP_pipelineabandon',
'updates': updates}]};
} else {
return $feature["q_x"];
}
... View more
08-06-2020
12:13 PM
|
2
|
2
|
9897
|
|
POST
|
Hi T L , When you use a "return" inside a loop, you exit the expression the first time it hits the return. To update multiple features you need to return a list with all the updates. Have a look at the variable "AddList" in the example "Edit another feature class with a calculation rule" at this page: Attribute rule script expression examples—ArcGIS Pro | Documentation .
... View more
08-05-2020
04:26 PM
|
2
|
5
|
9897
|
|
POST
|
Hi dafiter , See below a translation of the Excel formula into Arcade and the first lines to specify values for testing: var k = 2; // 1-5
var l = 3; // 1-3
var m = 3; // 1-3
var n = 1; // 1,4
var o = 1; // 1,2
var p = 1; // 1,2
var result = IIf((K==1 || K==4) && (L==2 || L==1) && (M==2 || M==1) && (N==1 || N==4) && (O==2 || O==1) && (P==2 || P==1), "0", IIf((K==2 || K==3 || K==5) && L==3 && M==3, "250","150"));
return result;
... View more
08-05-2020
06:26 AM
|
1
|
10
|
4126
|
|
POST
|
Hi Matt Creaney , Sorry for the delay. I just had a look at the webmap, but I have a couple of questions: None of the feature layers has any arcade expression defined. Where should the sequence begin? When you click on a feature of the "Production database" layer? I did not see a layer that has a field called "bay_guid", so it fails at line 18: $feature["bay_guid"] I was assuming that you would start with the Production database point features and wanted to extract information from the vehicles, but I am getting the idea that maybe you are starting from a table, but it is not clear how you want to do that. Below an example of a simple test to get a taste of the data: Note that I use the FeatureSetByRelationshipName to get to the related data: var Asset;
var DateOfVisit;
var IntersectCount;
var result;
var VehicleIntersecting;
var FirstAsset;
var AssetGeometry;
var AssetArea;
var Buffer_Distance = 100;
var AssetID;
var dateFormat = "MM/DD/Y";
//Get Date of Commission
Console($feature.CreationDate);
var DateOfCommission = Text($feature.CreationDate, dateFormat);
Console(DateOfCommission);
var bays = FeatureSetByRelationshipName($feature, "Bay");
Console("bays:" + count(bays));
var Asset_Area = Buffer($feature, Buffer_Distance, 'meters');
Console("Asset_Area:" + Area(Asset_Area, 'square-meters'));
var VehicleIntersecting = Intersects(FeatureSetById($map, /* Vehicle Locations */ "Vehicle_Locations_8121"), Asset_Area);
var IntersectCount = count(VehicleIntersecting);
Console("IntersectCount:" + IntersectCount);
result = IntersectCount + " vehicules found (" + DateOfCommission + ")";
if (IntersectCount > 0) {
for (var VehicleStop in VehicleIntersecting) {
//Get Date of Visit
var DateOfVisit = Text(VehicleStop.date_visited, dateFormat);
Console(DateOfVisit);
Console(DateOfCommission);
Console(result);
// Set result as Visit Duration if Dates of Visit and Commission Match
if (DateOfVisit == DateOfCommission) {
result += TextFormatting.NewLine + " - Visit Duration = " + VehicleStop.visit_duration;
} else {
result += TextFormatting.NewLine + " - Ignore Visit Duration (" + DateOfVisit + ") = " + VehicleStop.visit_duration;
}
}
} else {
result += TextFormatting.NewLine + " - No Intersecting Vehicle Record Found";
}
return result;
... View more
08-04-2020
02:27 PM
|
1
|
7
|
4841
|
|
POST
|
Hi Matt Creaney , I see that the IntersectCount is returning 0, so according to the expression there are no vehicles found within the buffer. To dig a little deeper it would help a lot to have access to (a part of) the data. If possible please create a group, share your data (or part of the data) to that group and invite me to that group using my user name "xbakker.spx".
... View more
08-03-2020
04:17 PM
|
0
|
10
|
4841
|
|
POST
|
Hi Anna Stamatogiannakis , Currently there is no support in ArcGIS Online, for interpreting HTML returned from a Arcade expression. It is something that is on the road map, but I am not sure when this will become available in the new map viewer.
... View more
08-03-2020
02:01 PM
|
0
|
1
|
1953
|
|
POST
|
Hi Anu Sawant , You would normally accomplish this using a Calculation Attribute Rule triggered by an Insert, but this functionality is not yet available in ArcGIS Online (it is in ArcGIS Enterprise and ArcGIS Pro). You can perform a calculation and when you detect a feature that has no Seriel_No, you could assign the next value to it, but you would need to schedule this as a task with a certain frequency and it will not be executed directly after a user creates a new feature.
... View more
08-03-2020
01:59 PM
|
1
|
2
|
2964
|
|
POST
|
Hi Matt Creaney , I would be nice to see what is written to the console. Could you post that too? A couple of observations to start with: On line 13 you extract year, month and day from a date to create a date and convert it to a text. You can apply the Text function directly on the data and supply a format if you only want to have the data and not the time On line 21 you create a SQL expression using a GlobalID. This query will not return any results. You have to change the query to get results: // either use:
var QueryBay = "GlobalID = @BayID";
// or complicate things and use:
var QueryBay = "GlobalID = '{" + Upper(BayID) + "}'";
Do this also for line 33 On line 41, don't use a loop if you only want to use the first asset. On line 60 apply Text directly on the data field and don't extract the year, month day to recreate the date When testing the arcade expression in the editor it may provide you a result (No Intersecting Vehicle Record Found), but this is probably since the validation is less strict. The query on the GlobalID is not valid and that is probably causing to not have any results.
... View more
08-03-2020
06:22 AM
|
1
|
12
|
4842
|
|
POST
|
Hi @Bud ,
That is a good question. In that presentation Jason Hine, shows a general picture of the platform and talks using Arcade to create content on the fly without changing your schema. That is true, but depending on where you apply this the scope of the functionality available will be different. Have a look at something called the profiles: Profiles | ArcGIS for Developers You will see that Arcade can be used in Attribute Rules, Field Calculates, Labeling, Popup, Visualization and a lot more.
You will also have to consider versions (have a look at the version matrix: Version Matrix | ArcGIS for Developers , and you will see that functionality will depend on the version of ArcGIS Pro | ArcGIS Enterprise server | ArcGIS Enterprise portal | ArcGIS JS API | ArcGIS Runtime). ArcGIS Online is not mentioned in the matrix since it always uses the latest version.
Some "profiles" offer a lot more functionality than others. Take for instance the pop-up where you can access other layers and tables. The Visualization and Labeling profiles will not offer this and the reason is performance. When you show a pop-up it will normally be a single pop-up at the time as opposed by visualizing thousands of features and labels in a map at the same time. That is why the complexity of an Arcade expression can be a lot higher in a pop-up and still be responsive.
If you can elaborate a little more on what you want to accomplish, I should be able to point you in the right direction and provide some examples.
... View more
07-30-2020
01:55 PM
|
2
|
3
|
5282
|
|
POST
|
Hi sfox_cpud , It sometimes happens that an OP does not respond to a possible solution (you may call it a "hit and run"), but I like to think that a possible solution might be useful not only to the OP but to others too. And in this case, thinking about this solution has helped me to create ideas that have been implemented at clients. So I don't feel I have wasted my time in any way. Thank for the shout out!
... View more
07-30-2020
09:42 AM
|
1
|
0
|
2135
|
|
POST
|
Hi Kevin Cheriyan , You can define a sequence that starts at the last number used in your field. It will take that number and whenever called, create the next number and never reuse a number. However, if a user would edit a record manually and use a number higher than the last number created by the sequence, you may run into duplicate numbers later on. This is not something that should happen, but if you would switch the calculation attribute rule off for some time and do manual edits, creating additional records and manually creating the unique number, your sequence will not be aware of that and duplicate number may be produced (just something to be aware of). To explain the Max (and other statistical functions) a bot more, you have two ways of using the function. One is using an array with numbers (as the example in the documentation shows). In that case you don't specify the second parameter (field name). However, when you use a featureset, you specify the featureset as the first parameter, but it will need the name of the field to perform the statistical function. That's why you have to use: Max(competitors, "Unique_ID")
... View more
07-29-2020
01:21 PM
|
0
|
0
|
8717
|
|
POST
|
Hi Kevin Cheriyan , Before going in to the Arcade expression you have, I would like to emphasize that there is something called a "sequence" which can create a unique number: Create Database Sequence (Data Management)—ArcGIS Pro | Documentation . There is an example of how to use it here: Attribute rule script expression examples—ArcGIS Pro | Documentation If you don't want to use sequences, you could change your expression to (notice that the Max function is used differently): var competitors = FeatureSetByName($datastore,"route.to.FeatureClass");
var maxid = Max(competitors, "ORIG_ID");
return maxid + 1;
... View more
07-29-2020
11:41 AM
|
4
|
4
|
8717
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-09-2020 09:26 AM | |
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|