Entity Using C#:
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
namespaceTest
{
publicclassDelete_record : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
if (context.MessageName == “Create” && context.PrimaryEntityName == “ms_intake”)
{
string intakeName = context.InputParameters[“Target”] is Entity entity && entity.Attributes.Contains(“ms_name”)
? entity[“ms_name”].ToString()
: null;
if (!string.IsNullOrEmpty(intakeName))
{
QueryExpression query = new QueryExpression(“ms_companyform”)
{
ColumnSet = new ColumnSet(“ms_companyformid”),
Criteria=newFilterExpression
{
Conditions=
{
new ConditionExpression(“ms_firstnamecomapny”, ConditionOperator.Equal, intakeName)
}
}
};
EntityCollection results = service.RetrieveMultiple(query);
foreach (var record in results.Entities)
{
service.Delete(“ms_companyform”, record.Id);
}
}
}
}
}
}
This functionality of a Dynamics 365 CRM plugin that triggers upon
There is a Two Entities I have created One is CompanyForm And another one is Intakes
In The Intakes Entity , If I create one record some name (for e.g., “Test Record”)
In Company Form already Created a record with the same
Once, I click save the record in Intakes Entity ,
Then the record will be delete Automatically in company form Entity.
For any Help or Queries Contact us on info@crmonce.com or +91 8096556344
https://www.crmonce.com/field-parameter-in-power-bi-desktop/