Answered by:
LINQ query - how do you check if the property bag is not null?

Question
-
I have the code below:
entity["new_message"] = (string)account.AccountName; is NULL in my case so I am getting a plug-in error.
- Edited by Sebd.DD Wednesday, October 28, 2015 8:38 AM
Saturday, October 24, 2015 6:58 PM
Answers
-
Try something like
lastName = accountSet.GetAttributeValue<string>("new_lastname");
Dynamics CRM MVP
My blog- Proposed as answer by Andrii ButenkoMVP, Moderator Sunday, October 25, 2015 5:40 PM
- Marked as answer by Mayank PujaraEditor Wednesday, October 28, 2015 10:59 AM
Sunday, October 25, 2015 9:05 AMModerator
All replies
-
Hello,
What is the plugin error you are getting? I did notice that you have a syntax error in the code you posted. You are missing an ending double-quotes on the following line:
where accountSet["new_lastname"].Equals("Marcus)
Hope that helps.
Saturday, October 24, 2015 8:09 PM -
Sorry, that was a type here; I have it correct in Visual Studio.
For instance in the above - I have a record that has the first name but not the last name. It is throwing an error because it cannot do: lastName = accountSet["new_lastname"],
How do I do something like:
if (accountSet["new_lastname"] != null)
{
lastName = accountSet["new_lastname"],
}
- Edited by Sebd.DD Saturday, October 24, 2015 9:13 PM
Saturday, October 24, 2015 8:12 PM -
Try something like
lastName = accountSet.GetAttributeValue<string>("new_lastname");
Dynamics CRM MVP
My blog- Proposed as answer by Andrii ButenkoMVP, Moderator Sunday, October 25, 2015 5:40 PM
- Marked as answer by Mayank PujaraEditor Wednesday, October 28, 2015 10:59 AM
Sunday, October 25, 2015 9:05 AMModerator -
Andrii, that worked thank you! How, nearly all the docs I read said to do it my way. I want to do a little more reading on your method, please can you adsvise on where I could start?Sunday, October 25, 2015 9:56 AM
-
- Proposed as answer by Andrii ButenkoMVP, Moderator Sunday, October 25, 2015 5:40 PM
Sunday, October 25, 2015 5:40 PMModerator