Answered by:
How to Check the NULL Values for lookup in plugin?

Question
-
Hi,
I want to check the NULL Values for lookup in plug-in
Thanks,
Srikanth Reddy
Friday, July 1, 2011 9:09 PM
Answers
-
Hi,
Becuase you are adding the lookup property into the entity whether it is null or not use code like this:
if (_cor != null)
{
emergcyeventent.Properties.Add(new LookupProperty("us_corid", _cor));
}
If this solves your problem please Mark it as Answer.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
- Proposed as answer by Jehanzeb.Javeed Friday, July 1, 2011 10:15 PM
- Marked as answer by RhettClintonMVP, Moderator Friday, July 1, 2011 11:42 PM
Friday, July 1, 2011 10:15 PM
All replies
-
If CRM Entity will contain lookup property then it will have value or else it will be Null.
CRM 4.0:
Lookup AccountEntityLookup = null;
// Checking if Entity has Lookup Field or if it is null then it will not be retrieved
If ( InputEntity.Properties.Contains ("new_account_entity_lookup") )
{
AccountEntityLookup = (Lookup)InputEntity["new_account_entity_lookup"];
}
CRM 2011:
EntityReference (Lookup type) contains thre attributes 1. id (Entity Record Unique Identifier) and 2. LogicalName (Entity Logical Name) 3. Name of Primary Attribute
EntityReference AccountEntityLookup = null;
// Checking if Entity has Lookup Field or if it is null then it will not be retrieved
If ( InputEntity.Contains ("new_account_entity_lookup") )
{
AccountEntityLookup = (EntityReference)InputEntity["new_account_entity_lookup"];
}
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
- Proposed as answer by Jehanzeb.Javeed Friday, July 1, 2011 9:46 PM
Friday, July 1, 2011 9:42 PM -
Hi Javeed,
If I assign null values also I am getting the same error like "The requested record was not found or you do not have the sufficient permission to view it"
Lookup
_cor = null;
)){
_cor = (
Lookup)_entity.Properties["us_corid"];
}
CreateResponse
Thanks,
Srikanth Reddy
Friday, July 1, 2011 10:08 PM -
Hi,
Becuase you are adding the lookup property into the entity whether it is null or not use code like this:
if (_cor != null)
{
emergcyeventent.Properties.Add(new LookupProperty("us_corid", _cor));
}
If this solves your problem please Mark it as Answer.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
- Proposed as answer by Jehanzeb.Javeed Friday, July 1, 2011 10:15 PM
- Marked as answer by RhettClintonMVP, Moderator Friday, July 1, 2011 11:42 PM
Friday, July 1, 2011 10:15 PM -
Hi Javeed,
Thanks a lot! It is working fine :)
Thanks,
Srikanth Reddy
Friday, July 1, 2011 10:31 PM -
Hi,
I am glad that the solution was helpful, please Vote as Helpful and Mark as Answer.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Friday, July 1, 2011 10:53 PM
Friday, July 1, 2011 10:44 PM