Show / Hide Table of Contents

    Class TargetItem

    The TargetItem class is a wrapper around the Target, PreImage, and PostImage of a plugin operation.

    Inheritance
    System.Object
    TargetItem
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Hsl.Xrm.Sdk.Plugin
    Assembly: Hsl.Xrm.Sdk.Plugin.dll
    Syntax
    public class TargetItem

    Constructors

    TargetItem(Entity, Entity, Entity, Int32, Int32, Boolean)

    Creates a new TargetItem instance.

    Declaration
    public TargetItem(Entity target, Entity preImage, Entity postImage, int index, int count, bool isCreate)
    Parameters
    Type Name Description
    Microsoft.Xrm.Sdk.Entity target

    The main target of the operation

    Microsoft.Xrm.Sdk.Entity preImage

    The preimage, if available

    Microsoft.Xrm.Sdk.Entity postImage

    The postimage, if available

    System.Int32 index

    The index for the order of the records in this message

    System.Int32 count

    The number of records in this message

    System.Boolean isCreate

    Whether the operation is a create message

    Properties

    Id

    The primary id of the record

    Declaration
    public Guid Id { get; }
    Property Value
    Type Description
    System.Guid

    Index

    The index of this record within the bulk operation

    Declaration
    public int Index { get; }
    Property Value
    Type Description
    System.Int32

    Input

    The main target input of the plugin operation

    Declaration
    public Entity Input { get; }
    Property Value
    Type Description
    Microsoft.Xrm.Sdk.Entity

    Item[String]

    Get the expected value of the field after the operation checking data in the postimage, target, then preimage (if available). OR sets a value to the target input record.

    Declaration
    public object this[string attribute] { get; set; }
    Parameters
    Type Name Description
    System.String attribute

    The logical name of the attribute.

    Property Value
    Type Description
    System.Object

    Value of the given attribute

    ItemIdentifier

    Text that can be put at the front of log or error messages indicating which record is being processed.

    Declaration
    public string ItemIdentifier { get; }
    Property Value
    Type Description
    System.String

    LogicalName

    The logical name of the record table

    Declaration
    public string LogicalName { get; }
    Property Value
    Type Description
    System.String

    Merged

    A combination of PostImage, Input (Target), and PreImage in that order that gives the latest values of the record.

    Declaration
    public Entity Merged { get; }
    Property Value
    Type Description
    Microsoft.Xrm.Sdk.Entity

    PostImage

    The postimage represents the value of the record after this operation was performed.

    Declaration
    public Entity PostImage { get; }
    Property Value
    Type Description
    Microsoft.Xrm.Sdk.Entity

    PreImage

    The preimage represents the value of the record before the update operation was performed.

    Declaration
    public Entity PreImage { get; }
    Property Value
    Type Description
    Microsoft.Xrm.Sdk.Entity

    Methods

    CreateException(String, Exception)

    Declaration
    public InvalidPluginExecutionException CreateException(string message, Exception innerException = null)
    Parameters
    Type Name Description
    System.String message
    System.Exception innerException
    Returns
    Type Description
    Microsoft.Xrm.Sdk.InvalidPluginExecutionException

    GetValue<T>(String)

    Get the expected value of the field after the operation checking data in the postimage, target, then preimage (if available).

    Declaration
    public T GetValue<T>(string attribute)
    Parameters
    Type Name Description
    System.String attribute

    The logical name of the attribute to get

    Returns
    Type Description
    T

    Value of the attribute

    Type Parameters
    Name Description
    T

    Type of the attribute to get

    IsFieldChanged(String)

    Whether the attribute has a different value between the target input and the preimage. Always returns true for create operations.

    Declaration
    public bool IsFieldChanged(string attribute)
    Parameters
    Type Name Description
    System.String attribute

    The logical name of the attribute to check

    Returns
    Type Description
    System.Boolean

    Whether the attribute was changed.

    Back to top Hsl.Xrm.Sdk