I have a form in CRM 2011 that contains a multi-line MEMO field.
I have a plugin that is supposed to get the data contained in that memo field.
I have a line of code that is supposed to retrieve the contents of the multiline memo box.
var AdditionalInformationPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_additionalInformationpri");
The procedure GetFieldStringData, that the code from above uses, is shown below.
protected string GetFieldStringData(IOrganizationService EntityService, LocalPluginContext EntityLocalContext, Entity PassedEntity, string PassedField)
{
IPluginExecutionContext context = EntityLocalContext.PluginExecutionContext;
EntityService = EntityLocalContext.OrganizationService;
ITracingService TracingSvc = EntityLocalContext.TracingService;
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
PassedEntity = (Entity)context.InputParameters["Target"];
//Entity new_s_testentity = (Entity)context.InputParameters["Target"];
try
{
var postImage = context.PostEntityImages["PostImageAddImportCheckToCheckRegister"];
PassedEntity = postImage;
var MyFieldValue = PassedEntity.GetAttributeValue<string>(PassedField);
if (String.IsNullOrEmpty(MyFieldValue))
{
try
{
var result = "NULL";
return result;
}
catch (Exception ex) { throw new Exception("Error in IF/TRY TransactionID Check: " + ex.Message); }
}
else
{
try
{
var result2 = MyFieldValue;
return result2;
}
catch (Exception ex) { throw new Exception("Error in ELSE/TRY TransactionID Check: " + ex.Message); }
}
}
catch (Exception ex) { throw new Exception("Error in GetFieldStringData: " + ex.Message); }
}
return null;
}
This works great with getting the value of single line text box items, but for some reason it's returning a null or empty when it executes against a record that has 2 lines of text in the memo field..
What am I doing wrong? There will be anywhere from 0 to 20 lines of text in this memo field. The specific record I am using as an example has 2 lines of text. Yet a value of null or empty is being returned instead of the expected text that's in there.
I am probably missing something in the code below.
If anyone can take a quick look and let me know what I am missing, that would be greatly appreciated.