One of the many strong points of Dynamics 365 Marketing is the separation of the Dynamics 365 environment and the Marketing services (see “Elements in a Marketing environment“)
This separation has a lot of advantages – including performance. However, the data in the Marketing services aren’t directly accessible to users
So what if you will want to tap into those interaction data? What if you are looking for a way to fire up an action card (or an email) to sellers if one of the contacts they own does something interesting, e.g. clicks a “learn more” link in a marketing email, or something similar?
Sure you can handle this in a customer journey, but what if you need logic for all emails in all customer journeys? Then you’ll need to tap into the interaction data in the Marketing Service.
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.
Recently we had a requirement to implement an approval workflow when a document is added to a SharePoint library.
Below is how we can implement it.
Details –
Trigger – When a file is created (properties only)
Specify the Site Address, Library Name, and the Folder on which the flow should run.
Initialize Variable
Initialize a variable VarComments to save all the responses.
Start and wait for an approval
Here we have used the Approval type as Custom Response – Wait for one response, we could also Approve / Reject – First to respond or any approval type based on the requirements.
The Assigned to field contains the name of the user who needs to review it.
The item link contains the link to the item.
Enable reassignment as Yes will allow the approver to reassign the approval to another user from the Approval Center.
Apply to each
Append the approval response to the variable VarComments.
Condition
If Outcome is Approved
If Yes – Update File Properties
Update the properties of the file using the ID.
Update the Approval Comments property with the variable.