The InputParameters property contains the data that is in the request message currently being processed by the event execution pipeline. Your plug-in code can access this data. The property is of type ParameterCollection where the keys to access the request data are the names of the actual public properties in the request. As an example, take a look at CreateRequest. One property of CreateRequest is named Target, which is of type Entity. This is the entity currently being operated upon by the platform. To access the data of the entity you would use the name “Target” as the key in the input parameter collection. You also need to cast the returned instance.
Note that not all requests contain a Target property that is of type Entity, so you have to look at each request or response. For example, DeleteRequest has a Target property, but its type is EntityReference. The preceding code example would be changed as follows.
// The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parameters. Entity entity = (Entity)context.InputParameters["Target"];
// The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference) { // Obtain the target entity from the input parameters. EntityReference entity = (EntityReference)context.InputParameters["Target"]; }
Once you have access to the entity data, you can read and modify it. Any data changes to the context performed by plug-ins registered in stage 10 or 20 of the pipeline are passed in the context to the core operation in stage 30.
Important
Not all fields in an entity record that are passed to a plug-in through the context can be modified. You should check the field’s IsValidForUpdate metadata property to verify that it isn’t set to false. Attempting to change the value of a field that can’t be updated results in an exception.
Similarly, the OutputParameters property contains the data that is in the response message, for example CreateResponse, currently being passed through the event execution pipeline. However, only synchronous post-event and asynchronous registered plug-ins have OutputParameters populated as the response is the result of the core platform operation. The property is of type ParameterCollection where the keys to access the response data are the names of the actual public properties in the response.
Below is the table to explain more about input parameters.
Below is the table to explain more about input parameters.
Message Request
|
InputParameter
|
Description
|
Create
|
Target
|
Target Contain the Entity with the attributes of current triggering record.
|
Update
|
Target
|
Target Contain the Entity with the attributes whose values have been modified, leadid
(primarykey of lead) as well those attributes that have forceSubmit true.
|
Delete
|
Target
|
Target Contain the EntityReference of deleted entity record.
|
Associate/Disassociate
|
Relationship,
Target, RelatedEntities |
Relationship Contain the Relationship name for which this plugin fired.
Target Contain the EntityReference of record. RelatedEntities Contain the EntityReferenceCollection of Related Entities record. |
Win/Lose
Request Opportunity
|
OpportunityClose
|
OpportunityClose Contain the Entity which is the activity that is created while performing the
Win/Lose operation and it contain the attribute opportunityid which give us
the opportunity on which this action is perform.
|
No comments:
Post a Comment