Notifications
Announcements
No record found.
Hi all
I need to get User Name in a custom workflow. I know how to get user id.
Please tell me. How can I get user name in a custom workflow.?
Thank You
*This post is locked for comments
Which User Name, The user who is running the workflow or some user field on entity?
Hi Saad Akhtar
User who run this custom workflow. Means User name belongs to this userid
ITracingService tracingService = context.GetExtension<ITracingService>();
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);
var id = workflowContext.UserId;
Hi,
Check the link below to get the current user.
www.crmanswers.net/.../get-current-user-inside-workflow.html
Hi Abi Rami
It is not my case. I need user on the basis of current user id, noparameters required in my case.
Hi Abdul
The information will be easily available in the organisationservice context,its something similar to the getting the username in the plugin.
create a query expression using the userid on systemuser entity and get full name of the user.
Hi Sumit Gupta
But How?
Hi Abdul Wahab,
If you get the user id, then you could retrieve the username using the following function.
function GetUserName(userId) {var cols = ["domainname"];var resultXml = XrmServiceToolkit.Soap.Retrieve("systemuser", userId, cols);if (resultXml != null && resultXml.attributes['domainname'] != null) { var username = resultXml.attributes['domainname'].value; } }
Use this code:
Entity User = service.Retrieve("systemuser", context.UserId, new ColumnSet(new String[] {"fullname"})); if (User != null) { if (User.Attributes.Contains("fullname") && User.Attributes["fullname"] != null) { string UserName = ((string)User.Attributes["fullname"]); } }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2