//Get Field Data - TEXT
var CheckStagingID = GetFieldStringData(service, localContext, new_s_checkstaging, "new_chkstagenum");
var AddressLine1Pri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_addressline1pri");
var AddressLine1Sec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_addressline1sec");
var AddressLine2Pri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_addressline2pri");
var AddressLine2Sec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_addressline2sec");
var BankCode = GetFieldStringData(service, localContext, new_s_checkstaging, "new_bankcode");
var BusinessNamePri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_businessname");
var BusinessNameSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_businessnamesec");
var CheckCatalogNum = GetFieldStringData(service, localContext, new_s_checkstaging, "new_checkcatalognumber");
var CheckNum = GetFieldStringData(service, localContext, new_s_checkstaging, "new_checknum");
var CheckYear = GetFieldStringData(service, localContext, new_s_checkstaging, "new_checkyear");
var CheckStagingNumber = GetFieldStringData(service, localContext, new_s_checkstaging, "new_chkstagenum");
var CityPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_citypri");
var CitySec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_citysec");
var FirstNamePri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_firstnamepri");
var FirstNameSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_firstnamesec");
var IssueReason = GetFieldStringData(service, localContext, new_s_checkstaging, "new_issuereasonlong");
var IssuingDepartment = GetFieldStringData(service, localContext, new_s_checkstaging, "new_issuingdepartmentlong");
var LastNamePri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_lastnamepri");
var LastNameSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_lastnamesec");
var MiddleNamePri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_middlenamepri");
var MiddleNameSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_middlenamesec");
var OwnerTypeDescriptionPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_otypelongpri");
var OwnerTypeDescriptionSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_otypelongsec");
var OwnerRelationshipPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownerrelationship");
var OwnerRelationshipSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownerrelationshipsec");
var OwnerStatusPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownerstatuslong");
var OwnerStatusSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownerstatuslongsec");
var CorporateStatusPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownertypelong");
var CorporateStatusSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ownertypelongsec");
var PropertyOwnerType = GetFieldStringData(service, localContext, new_s_checkstaging, "new_potype");
var RecordOwner = GetFieldStringData(service, localContext, new_s_checkstaging, "new_recowner");
var StatusCode = GetFieldStringData(service, localContext, new_s_checkstaging, "new_scode");
var SSNTAXIDNum = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ssntaxid");
var SSNTAXIDNumSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_ssntaxidsec");
var ZipCodePri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_zipcodepri");
var ZipCodeSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_zipcodesec");
//Get Field Data - LOOKUP
var Bank = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_bank");
var IssueReasonCode = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_issuereason");
var CheckID = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_checkmanagementid");
var IssuingDepartmentCode = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_issuingdepartment");
var PrefixPri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_nameprefixpri");
var PrefixSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_nameprefixsec");
var SuffixPri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_namesuffixpri");
var SuffixSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_namesuffixsec");
var NumofOwners = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_numberofowners");
var OwnerTypePri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_otypecodepri");
var OwnerTypeSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_otypecodesec");
var OwnerRelationshipCodePri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownerrelationshipcode");
var OwnerRelationshipCodeSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownerrelationshipcodesec");
var OwnerStatusCodeSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownerstatuscodesec");
var OwnerStatusCodePri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownerstatuspri");
var CorporateStatusCodeSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownertypecodesec");
var CorporateStatusCodePri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_ownertypepri");
var StatePri = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_statepri");
var StateSec = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_statesec");
var SubmissionStatus = GetLookupFieldGuid(service, localContext, new_s_checkstaging, "new_s_checkstaging", "new_submissionstatus");
//Get Field Data - MEMO
var AdditionalInformationSec = GetFieldStringData(service, localContext, new_s_checkstaging, "new_additionalInformationasec");
var AdditionalInformationPri = GetFieldStringData(service, localContext, new_s_checkstaging, "new_additionalInformationpri");
//throw new Exception("The Bank GUID is: " + Bank +
// " ,the Issue Reason Code is: " + IssueReasonCode +
// ", the Check ID is: " + CheckID +
// ", the Issuing Dept Code is: " + IssuingDepartmentCode +
// ", the Prefix(Pri) is: " + PrefixPri +
// ", the Prefix(Sec) is: " + PrefixSec +
// ", the Suffix(Pri) is: " + SuffixPri +
// ", the Suffix(Sec) is: " + SuffixSec +
// ", the NumofOwners is: " + NumofOwners +
// ", the OwnerType(Pri) is: " + OwnerTypePri +
// ", the OwnerType(Sec) is: " + OwnerTypeSec +
// ", the OwnerRelationshipCode(Pri) is: " + OwnerRelationshipCodePri +
// ", the OwnerRelationshipCode(Sec) is: " + OwnerRelationshipCodeSec +
// ", the OwnerStatusCode(Pri) is: " + OwnerStatusCodePri +
// ", the OwnerStatusCode(Sec) is: " + OwnerStatusCodeSec +
// ", the CorporateStatusCode(Pri) is: " + CorporateStatusCodePri +
// ", the CorporateStatusCode(Sec) is: " + CorporateStatusCodeSec +
// ", the State(Pri) is: " + StatePri +
// ", the State(Sec) is: " + StateSec +
// ", the SubmissionStatus is: " + SubmissionStatus +
// ", the AdditionalInformationPri is: " + AdditionalInformationPri +
// ", the AdditionalInformationSec is: " + AdditionalInformationSec);
//BUSINESS LOGIC FUNCTIONS
protected string GetLookupFieldGuid(IOrganizationService EntityService, LocalPluginContext EntityLocalContext, Entity PassedEntity, string CurrentEntity, string LookupFieldName)
{
IPluginExecutionContext context = EntityLocalContext.PluginExecutionContext;
EntityService = EntityLocalContext.OrganizationService;
ITracingService TracingSvc = EntityLocalContext.TracingService;
// Get the context
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
//PassedEntity = (Entity)context.InputParameters["Target"];
//Entity new_s_testentity = (Entity)context.InputParameters["Target"];
try
{
//Lookup Attribute: new_MyLookupattribute,
//Current Entity: new_myentity,
ColumnSet myAttributes = new ColumnSet(new String[] { LookupFieldName });
Entity myEntityHavingLookup = EntityService.Retrieve(CurrentEntity, PassedEntity.Id, myAttributes);
if (((Microsoft.Xrm.Sdk.EntityReference)(myEntityHavingLookup.Attributes[LookupFieldName])).Id != null)
{
var myLookupId = ((Microsoft.Xrm.Sdk.EntityReference)(myEntityHavingLookup.Attributes[LookupFieldName])).Id;
var myLookupName = ((Microsoft.Xrm.Sdk.EntityReference)(myEntityHavingLookup.Attributes[LookupFieldName])).Name;
var MyGUIDAsString = myLookupId.ToString();
return MyGUIDAsString;
}
else { return "NULL"; }
}
//catch (Exception ex) { throw new Exception("Error in GetTransactionMethod: " + ex.Message); }
catch {return "NULL"; }
}
else
{
try
{
var result2 = "BLANK";
return result2;
}
catch (Exception ex) { throw new Exception("Error in ELSE/TRY TransactionID Check: " + ex.Message); }
}
}
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 MyFieldValue = PassedEntity.GetAttributeValue<string>(PassedField);
//var TranscationID = PassedEntity.GetAttributeValue<string>("new_testentityinfoid");
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 GetTransactionMethod: " + ex.Message); }
}
return null;
}