I need userId of current user in Custom Workflows of Microsoft Dynamics CRM 2011. So can you suggest me how to get it?
Assuming that you are using c#, and that you created your custom workflow following Create a Custom Workflow Activity article from MSDN, it should inherit CodeActivity class, and has a method like:
protected override void Execute(CodeActivityContext context)
{
// Your code here
}
To get the current userId
, you need to obtain the IWorkflowContext
from the CodeActivityContext
, like this:
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
And then:
var id = workflowContext.UserId;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With