Recently we got the below issue while saving the contact record. It was throwing this for one of our plugin steps registered on the update, for which we had already removed the profiling.
The profiling was already removed from the step.
It was the same error while trying to uninstall the profiler.
As mentioned in the error message we checked the Plug-in Profiler assembly in the Plugin Registration tool and could find the reference to the step there.
Recently we had a requirement to capture the date when a lead is qualified. Here we can create a new date time attribute to capture the lead qualification date and update this field either through workflow, flow, or plugin on lead qualification.
Status Code = 3 (Qualified)
We implemented a plugin on PreOperation – Update of lead, with filtering attributes as the state code.
Below is the sample code for the plugin –
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
try
{
tracingService.Trace("start plugin execution: {0}", this.GetType().FullName);
// plugin is in pre update stage of lead
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity &&
context.MessageName.Equals("update", StringComparison.OrdinalIgnoreCase) &&
context.Stage == 20)
{
var leadEntity = (Entity)context.InputParameters["Target"];
if(leadEntity.LogicalName == "lead")
{
if(leadEntity.Attributes.Contains("statuscode") &&
((OptionSetValue)leadEntity.Attributes["statuscode"]).Value == 3
)
{
tracingService.Trace("Lead with Id {0} is getting qualified at {1}",
leadEntity.Id.ToString(), DateTime.UtcNow);
// the custom date time field to capture the qualification date
leadEntity["custom_qualificationdate"] = DateTime.UtcNow;
}
}
}
tracingService.Trace("end plugin execution: {0}", this.GetType().FullName);
}
catch (System.ServiceModel.FaultException<OrganizationServiceFault> ex)
{
tracingService.Trace(ex.Detail.Message);
throw;
}
catch (Exception ex)
{
tracingService.Trace(ex.ToString());
throw;
}
}
It’s possible to get related records of a relationship when we retrieve a parent record using RelatedEntitiesQuery property in the RetrieveRequest. That means you have to construct the RetrieveRequest not using the Retrieve method from the OrganizationServiceProxy class.
Suppose we have 3 tables, Table A, Table B, and Table C related to each other as
Table A (n-1) Table B (n-1) Table C i.e.
Table A has a lookup of Table B and Table B has a lookup of Table C.
Below is our sample canvas app that has a gallery and a combo box.
What we would want is based on the Table C record’s name selected in the combo box, we want to filter the collection to only show those records that are related to it.
One of the ways we could implement this is by using the AddColumns to add Table C data to Table A and apply the Filter to it.
Below is the formula to achieve the same.
In Table A, add a column name “TableCName”.
To get the Table C name, perform a Lookup on Table B, where Table B GUID is equal to Table A’s Table B lookup field, and then fetch the Table C Lookup’s name from Table B.
And lastly, perform a Filter on this new column TableCName, based on the selected value in the combo box.