Plugin fires before transaction commit and tries to check the previous OST1 record id .How to over come this??
. I have a pre-operation synchronous plugin . I have sm custom code written ans have a relation between OST1 entity and OSTY1 entity.
Plugin validates is there any record OSTY1 for a given combination of OST1 and fiscal year.
var queryExpression = new QueryExpression("OSTY1");
queryExpression.ColumnSet = new ColumnSet(new[] { "kpmg_name" });
queryExpression.Criteria.AddCondition("OSST1id", ConditionOperator.Equal, opportunityServiceTypeValue.Id);
queryExpression.Criteria.AddCondition("kpmg_fiscalyear", ConditionOperator.Equal, fiscalYearValue.Id);
queryExpression.Criteria.AddCondition("statecode", ConditionOperator.Equal,0);
EntityCollection results = orgService.RetrieveMultiple(queryExpression);
bool doesDuplicateExist = false;
if (results != null && results.Entities.Count > 0)
{
if (results.Entities.Count > 1)
{
doesDuplicateExist = true;
}