Answered by:
Retrieve a value in Plugin

Question
-
Hi,
I have a plugin that is fired on update of a field of a custom entity. I want to check the field value in the form in my plugin code. How can i retrieve this field value in my plugin. The field is a simple text field. If u can provide a sample code it would be helpful.
thanks in advance,
Wednesday, November 9, 2011 1:56 PM
Answers
-
In CRM 2011, it is Entity. To read the Post Image you need to use the following code
Entity entity = (Entity)context.PostEntityImages["<PostImage>"]; // PostImage is the alias name that was used when registering the plugin using plugin registration tool
You first need to register a post image at the time of registering the plugin. Make sure to include all the attributes that you want to access within the plugin.
You can then access the value of that property from Entity and perform further operations.
HTH
Sam
Web: http://www.inogic.com
Blog: http://inogic.blogspot.com
Email: news@inogic.com
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Sam - Inogic Thursday, November 10, 2011 6:23 AM
- Marked as answer by Prasad Parameswaran Wednesday, January 18, 2012 4:45 AM
Thursday, November 10, 2011 6:22 AM
All replies
-
Hi Prasad ,
you need to trap the post update message
Also make sure that you register the Post Image.
Here is a example
//Cast it into a DynamicEntity
DynamicEntity postEntity = (DynamicEntity)context.PostEntityImages["PostImage"];
String newName = (String)postEntity["new_name"];--------------------------------------------------------------------------------
If this answer your question, could you mark the my post as answer.
--------------------------------------------------------------------------------Dkay
- Proposed as answer by Tanguy T [MVP CRM]MVP, Moderator Wednesday, November 9, 2011 4:38 PM
Wednesday, November 9, 2011 3:09 PM -
Hi,
I am using CRM 2011. Is Dynamic entity supported in 2011 plugin . If not what is that i need to change in order to get it to work for CRM 2011 and where should i include the post image in this code.
if (context.InputParameters.Contains("Target"
) &&
context.InputParameters[
"Target"] is Entity
)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];
Thanks in advance,
Thursday, November 10, 2011 5:15 AM -
In CRM 2011, it is Entity. To read the Post Image you need to use the following code
Entity entity = (Entity)context.PostEntityImages["<PostImage>"]; // PostImage is the alias name that was used when registering the plugin using plugin registration tool
You first need to register a post image at the time of registering the plugin. Make sure to include all the attributes that you want to access within the plugin.
You can then access the value of that property from Entity and perform further operations.
HTH
Sam
Web: http://www.inogic.com
Blog: http://inogic.blogspot.com
Email: news@inogic.com
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Sam - Inogic Thursday, November 10, 2011 6:23 AM
- Marked as answer by Prasad Parameswaran Wednesday, January 18, 2012 4:45 AM
Thursday, November 10, 2011 6:22 AM