Unable to profile Custom Workflow using Profiler – Quick Fix

Hi Folks,

I am a big fan of Power Automate…but this post is not about flows but features about Custom Workflow in Dynamics 365 CE.

Did you ever come across this problem where you were not able to debug custom workflow extension. I had come across this and this blog post is all about it…I successfully registered my Custom workflow, but it is not triggering at all.

So, I need to debug it to see what the exact issue was…as I am encounter this error.

Error message says Duplicate workflow activity group name: ‘EcellorsDemo.Cases(1.0.0.0) (Profiled)‘. So, I tried to check my code, plugin steps and any activated plugins but couldn’t find any duplicates.

Usually while debugging your custom workflow using profiler, your workflow will go into draft mode and another copy of the same workflow gets created with name of (Profiled) attached to the name. However, in my case, I didn’t see the same behavior and at the same time, I was unable to use Profiler after the first profiling session and it gave me error shown above.

In order to resolve, this just delete the Plugin Assemblies which could find in the default solution like highlighted below…

Once you have deleted this, try to debug the custom workflow and voila!!!

Hope this helps someone troubleshooting Custom workflow…!

Cheers,

PMDY

Update user personal settings Automatically easily when a new user gets added to Dynamics 365 Environments

Hi Folks,

In the Dynamics 365 world, it’s all about efficiently handling the user requests. Whenever you add any user to the environment, the system will update the default personal settings for the user. Maybe you could have some processes in your system which is dependent on the user time zone. So, setting the time zone is very important. It is tedious to update the personal settings manually going to the user profile and updating it manually every time.

In case you want to do it for all users at one time during initial setup, you can follow my blog post Update Model Driven App Personal Settings from XrmToolBox.

Of course, you have a wonderful tool in XrmToolBox from which we will be able to set the User Personal Settings in bulk so that we can update to all the users in one go. What if we want to automate this process, i.e. whenever you add a new user to the Dynamics 365 environment, you want to set that person time zone automatically without any manual intervention.

There you go…this post is for you then…you can do it simply using Plugin or Power Automate. In this blog post, we will see how we can utilize the Plugin as it is more effective approach.

You need to write a Plugin on Associate Message.

Just use this piece of code to set Personal settings…

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Messages;
namespace Ecellors_Demo
{
public class Demo : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the tracing service
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Relationship"))
{
var relationshipName = context.InputParameters["Relationship"].ToString();
try
{
if (relationshipName != "systemuserroles_association.")
{
return;
}
if (context.MessageName == "Associate")
{
//logic when role added
var updateUserSettingsRequest = new UpdateUserSettingsSystemUserRequest();
updateUserSettingsRequest.Settings = new Entity("usersettings");
updateUserSettingsRequest.UserId = context.UserId;
updateUserSettingsRequest.Settings.Attributes["timezonecode"] = 215;//Singapore timezone
service.Execute(updateUserSettingsRequest);
}
if (context.MessageName == "Disassociate")
{
//logic when role removed
var updateUserSettingsRequest = new UpdateUserSettingsSystemUserRequest();
updateUserSettingsRequest.Settings = new Entity("usersettings");
updateUserSettingsRequest.UserId = context.UserId;
updateUserSettingsRequest.Settings.Attributes["timezonecode"] = 0;//UTC timezone
service.Execute(updateUserSettingsRequest);
}
else
{
return;
}
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in UserSettingsPlugin.", ex);
}
catch (Exception ex)
{
tracingService.Trace("UserSettingsPlugin: {0}", ex.ToString());
throw;
}
}
}
}
}

Update the personal settings as per your needs in this request. You can find all the attributes of the user settings table by using Fetch Xml Builder easily.

Hope this helps someone.

Cheers,

PMDY