I have try many codes around but still not working, i'm new in dev in dynamics crm 2011. i have create new custom entity "new_smsmessage" who has many to many relationship with User entity, i'm writing plugin to send sms to many users, and i need in my plugin to retreive users mobilenumber, i use the code bellow to retrieve userId but get all the time the error message in the crm "The given key was not present in the disctionary" any help plz :
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.Attributes.Contains("new_smsmessage") == false)
{
string smstext = entity.Attributes["new_message"].ToString();
string smsnumber = entity.Attributes["new_phonenumber"].ToString();
EntityReference userlookup = (EntityReference)entity["systemuser"];
string receipient = userlookup.Name.ToString();
}
}