Select to view content in your preferred language

string expression parameter in EditOperation.TransferAttributes overload?

145
1
Jump to solution
11-07-2024 01:48 PM
KerryAlley
Frequent Contributor

Simple question, I hope: 

What kind of "override" string expression is expected in this EditOperation.TransferAttributes overload method?  Does anyone have an example or know of relevant documentation?

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hello, 

Here is a sample of the expression that can be used to map field values between two features or rows with the EditOperation.TransferAttributes function.

return {
"ADDRESS" : $sourceFeature['ADDRESS'],
"IMAGE" : $sourceFeature['IMAGE'],
"PRECINCT" : $sourceFeature['PRECINCT'],
"WEBSITE" : $sourceFeature['WEBSITE'],
"ZIP" : $sourceFeature['ZIP']
}

 

Here's an example of a simple button that will transfer attributes from a source feature (oid 1) in the Police Stations layer to a destination feature  (oid 2) in the same layer

 

 

protected override void OnClick()
{
  var layer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == "Police Stations");
  if (layer == null)
    return;

  string expression = "return {\r\n  " +
      "\"ADDRESS\" : $sourceFeature['ADDRESS'],\r\n  " +
      "\"IMAGE\" : $sourceFeature['IMAGE'],\r\n  + " +
      "\"PRECINCT\" : $sourceFeature['PRECINCT'],\r\n  " +
      "\"WEBSITE\" : $sourceFeature['WEBSITE'],\r\n  " +
      "\"ZIP\" : $sourceFeature['ZIP']\r\n " +
      "}";

  QueuedTask.Run(() =>
  {
    var op = new EditOperation();
    op.Name = "Transfer atts";

    op.TransferAttributes(layer, 1, layer, 2, expression);

    var success = op.Execute();
  });
}

 

I'll make sure the documentation for the function is updated.   Let me know if you have any additional questions.

Narelle

View solution in original post

0 Kudos
1 Reply
NarelleChedzey
Esri Contributor

Hello, 

Here is a sample of the expression that can be used to map field values between two features or rows with the EditOperation.TransferAttributes function.

return {
"ADDRESS" : $sourceFeature['ADDRESS'],
"IMAGE" : $sourceFeature['IMAGE'],
"PRECINCT" : $sourceFeature['PRECINCT'],
"WEBSITE" : $sourceFeature['WEBSITE'],
"ZIP" : $sourceFeature['ZIP']
}

 

Here's an example of a simple button that will transfer attributes from a source feature (oid 1) in the Police Stations layer to a destination feature  (oid 2) in the same layer

 

 

protected override void OnClick()
{
  var layer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == "Police Stations");
  if (layer == null)
    return;

  string expression = "return {\r\n  " +
      "\"ADDRESS\" : $sourceFeature['ADDRESS'],\r\n  " +
      "\"IMAGE\" : $sourceFeature['IMAGE'],\r\n  + " +
      "\"PRECINCT\" : $sourceFeature['PRECINCT'],\r\n  " +
      "\"WEBSITE\" : $sourceFeature['WEBSITE'],\r\n  " +
      "\"ZIP\" : $sourceFeature['ZIP']\r\n " +
      "}";

  QueuedTask.Run(() =>
  {
    var op = new EditOperation();
    op.Name = "Transfer atts";

    op.TransferAttributes(layer, 1, layer, 2, expression);

    var success = op.Execute();
  });
}

 

I'll make sure the documentation for the function is updated.   Let me know if you have any additional questions.

Narelle

0 Kudos