Analysis of input object parameters of CRM Learning

Source: Internet
Author: User

 

1. Problem Description

Recently, a post event plug-in was created. The input parameters are handled as follows:

 
1:If(Context. inputparameters. Contains ("Target") & Context. inputparameters ["Target"] Is entity)
 
2 :{
3: entity = (entity) Context. inputparameters ["Target"];
 
4 :...
 
5:
 
6 :}
 
7:
 
Unit test is also normal pass:
 

 

However, when I published the plug-in, I found an error. It was strange that the unit test passed!

 

2. solution 1

Then, retrieve the object parameter again before calling it. Everything is normal:

 
1: entity = service. Retrieve (current. logicalname, current. ID,NewColumnset (NewString [] {all }));
2:

Later, we found that only some changed attributes of the passed object parameters have values, but those that have not changed are not included.

 

 

3. solution 2

So can we bring in the desired attribute? Yes, that is to say, we don't need to take this object again in the plug-in.

The method is to use "pre-events and post-entity images"

Preentityimages and postentityimages include snapshots of the primary object attributes before (pre) and after (post) operations on the core platform. Microsoft Dynamics CRM fills in the previous and later entity images based on the security permissions of simulated system users. Only a value orNullThe object property is available in the previous or later stage of the object image. When you register your plug-in, you can specify to fill these with the PlatformPreentityimagesAndPostentityimagesAttribute. The plug-in code uses the entity alias value you specified during plug-in registration as the key value of the image set in the plug-in code.

Some events do not have images available. For example, postentityimages is only filled with synchronous post-event and asynchronous registration plug-ins. Pre-image creation is not supported, and post-image deletion is not supported.

Specifically, after registering the plug-in and adding a step, right-click the step and select register a new image.

You can specify the name and attributes of the plug-in:

 

If this parameter is specified, it is not used at the beginning of the plug-in,

Entity entity = (entity) Context. inputparameters ["target"];

Instead, we use the following method:

(Entity) Context. preentityimages ["image"];

 

In this way, you do not need to take the other attributes of the object again in the plug-in.

Analysis of input object parameters of CRM Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.