How to get the Impersonation User Id(systemUserId ) in D365
public Guid getUserId(IOrganizationService service, string userName) { Guid systemUserId = Guid.Empty; try { QueryByAttribute queryByAttribute = new QueryByAttribute("systemuser"); ColumnSet columns = new ColumnSet("systemuserid"); queryByAttribute.AddAttributeValue("fullname", userName); EntityCollection retrieveUser = service.RetrieveMultiple(queryByAttribute); systemUserId = ((Entity)retrieveUser.Entities[0]).Id; } catch (FaultException<OrganizationServiceFault> e) { throw new Exception("Error: >>" + e.Message); } return systemUserId; } IOrganizationService systemService = serviceFactory.CreateOrganizationService(getUserId(service, “SYSTEM”)); Note: Whenever we run the workflow on-demand, we get the U