ArcGIS Pro 3.5 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / TransferAttributes Method / TransferAttributes(MapMember,Int64,MapMember,Int64,String) Method
The source mapMember.
The source feature (or row)'s OID
The target mapMember
The target feature (or row)'s OID
The override expression to assign values to target fields.
Example

In This Topic
    TransferAttributes(MapMember,Int64,MapMember,Int64,String) Method
    In This Topic
    Transfer attributes between two features or rows using the supplied Arcade expression.
    Syntax
    public void TransferAttributes( 
       MapMember source,
       long sourceOID,
       MapMember target,
       long targetOID,
       string expression
    )
    Public Overloads Sub TransferAttributes( _
       ByVal source As MapMember, _
       ByVal sourceOID As Long, _
       ByVal target As MapMember, _
       ByVal targetOID As Long, _
       ByVal expression As String _
    ) 

    Parameters

    source
    The source mapMember.
    sourceOID
    The source feature (or row)'s OID
    target
    The target mapMember
    targetOID
    The target feature (or row)'s OID
    expression
    The override expression to assign values to target fields.
    Remarks
    The expression is called with the source and target features to determine what changes (if any) to make to the target feature.

    If the expression is set to null, then the application field mapping stored for the source and target mapMembers will be used to transfer attributes.

    If the expression is set to the empty string, then only the attributes in the source feature that auto-match (based on name) with attributes in the target feature will be transferred.

    A custom expression that provides a simple field mapping between source and target features should look similar to the following

    return {

    "ADDRESS" : $sourceFeature['ADDRESS'],

    "IMAGE" : $sourceFeature['IMAGE'],

    "PRECINCT" : $sourceFeature['PRECINCT'],

    "WEBSITE" : $sourceFeature['WEBSITE'],

    "ZIP" : $sourceFeature['ZIP']

    }

    A more complex custom expression that uses Arcade functions to transfer attributes is as follows

    return {

    "NAME" : $sourceFeature['FIRST_NAME'] + ' ' + $sourceFeature['LAST_NAME'],

    "PERCENT" : Round($sourceFeature['POPULATION'] * 100, 2)

    }

    Additional Arcade information can be found here.

    Example
    Edit Operation: Transfer Attributes
    var transferAttributes = new EditOperation() { Name = "Transfer Attributes" };
    
    // transfer attributes using the stored field mapping
    transferAttributes.TransferAttributes(featureLayer, oid, destinationLayer, targetOID);
    
    // OR transfer attributes using an auto-match on the attributes
    transferAttributes.TransferAttributes(featureLayer, oid, destinationLayer, targetOID, "");
    
    // OR transfer attributes using a specified set of field mappings
    //  dictionary key is the field name in the destination layer, dictionary value is the field name in the source layer
    var fldMapping = new Dictionary<string, string>();
    fldMapping.Add("NAME", "SURNAME");
    fldMapping.Add("ADDRESS", "ADDRESS");
    transferAttributes.TransferAttributes(featureLayer, oid, destinationLayer, targetOID, fldMapping);
    
    // OR transfer attributes using a custom field mapping expression
    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 " +
        "}";
    transferAttributes.TransferAttributes(featureLayer, oid, destinationLayer, targetOID, expression);
    
    //Execute to execute the operation
    //Must be called within QueuedTask.Run
    if (!transferAttributes.IsEmpty)
    {
      var result = transferAttributes.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
    }
    
    //or use async flavor
    //await transferAttributes.ExecuteAsync();
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also