private static void duplciatedetection(Entity target, IOrganizationService service, ITracingService tracingService)
{
Entity targetEntity = (Entity)target["Target"];
if (targetEntity.LogicalName == "Subgrid_new_1")
{
OptionSetValue optionSetValue = target.GetAttributeValue<OptionSetValue>("A");
EntityReference lookupValue = target.GetAttributeValue<EntityReference>("B");
QueryExpression query = new QueryExpression("Subgrid_new_1");
query.Criteria.AddCondition("A", ConditionOperator.Equal, optionSetValue.Value);
query.Criteria.AddCondition("B", ConditionOperator.Equal, lookupValue.Id);
EntityCollection results = service.RetrieveMultiple(query);
if (results.Entities.Count > 0)
{
throw new InvalidPluginExecutionException("A record with the same Option Set value and Lookup value already exists in the subgrid.");
}
}
}
Hi Manth ,
I have done a similar thing before
You should get the column values using columnset.
just try the below snippet
queryExpression.ColumnSet = new ColumnSet("fullname", "emailaddress1", "parentcustomerid"); queryExpression.Criteria.AddCondition("fullname".ToLower(), ConditionOperator.Equal, fullName.ToLower()); queryExpression.Criteria.AddCondition("emailaddress1", ConditionOperator.Equal, email); queryExpression.Criteria.AddCondition("parentcustomerid", ConditionOperator.Equal, parentCustomerId.Id);
if this answer helps you, like and verify my answer
Subgrid_new_1 is not a logical name even if i use the subgrid logical name i am facing same issue as above code.
Fast reply is most helpful.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156