Table of Contents

Interface ITargetItem

Namespace
Hsl.Xrm.Sdk
Assembly
Hsl.Xrm.Sdk.Core.dll

The ITargetItem interface is a wrapper around the Target, PreImage, and PostImage of a plugin operation.

public interface ITargetItem

Properties

Id

Primary id of the record

Guid Id { get; }

Property Value

Guid

Index

The index of this record within the bulk operation

int Index { get; }

Property Value

int

Input

The main target input of the plugin operation.

Entity Input { get; }

Property Value

Entity

this[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.

object? this[string attribute] { get; set; }

Parameters

attribute string

The logical name of the attribute.

Property Value

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.

string ItemIdentifier { get; }

Property Value

string

LogicalName

The logical name of the record table

string LogicalName { get; }

Property Value

string

Merged

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

Entity Merged { get; }

Property Value

Entity

PostImage

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

Entity? PostImage { get; }

Property Value

Entity

PreImage

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

Entity? PreImage { get; }

Property Value

Entity

Methods

CreateException(string, Exception?)

InvalidPluginExecutionException CreateException(string message, Exception? innerException = null)

Parameters

message string
innerException Exception

Returns

InvalidPluginExecutionException

GetValue<T>(string)

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

T? GetValue<T>(string attribute)

Parameters

attribute string

The logical name of the attribute to get

Returns

T

Value of the attribute

Type Parameters

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.

bool IsFieldChanged(string attribute)

Parameters

attribute string

The logical name of the attribute to check

Returns

bool

Whether the attribute was changed.