Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

User name oncreate plugin Postoperation

Posted on by 165

Hi All ,

I'm trying to get username who is creating the records oncreate plugin which is on Postoperation .

Below is my code , it does not work:

IOrganizationService organizationService = serviceFactory.CreateOrganizationService(context.UserId);
Entity systemuser = organizationService.Retrieve("systemuser", context.UserId, new ColumnSet("fullname"));
string usersy = systemuser.Attributes["fullname"].ToString();

  • Suggested answer
    Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: User name oncreate plugin Postoperation

    Hello Shahzeb,

    Please try with: Guid systemUserId = (Guid)context.InputParameters["SystemUserId"]; . Before going with this approach, you could do some debugging first to see what attributes are coming as input parameter.

    regards,

    Please mark this as answered if this helps you to resolve the issue.

  • Suggested answer
    Shahzeb Khan Profile Picture
    Shahzeb Khan 165 on at
    RE: User name oncreate plugin Postoperation

    i resolved it , i had been using some fundamental mistake, below is the right one .

    Entity systemuser = organizationService.Retrieve("systemuser", context.UserId, new ColumnSet("fullname"));

    string usersy = systemuser.Attributes["fullname"].ToString();

  • Shahzeb Khan Profile Picture
    Shahzeb Khan 165 on at
    RE: User name oncreate plugin Postoperation

    error : the given dictionary is not found .

    Noet: Plugin is in postoperation oncreate

    IOrganizationService organizationService = serviceFactory.CreateOrganizationService(context.UserId);

    Entity systemuser = organizationService.Retrieve("systemuser", context.UserId, new ColumnSet("createdby"));

    string usersy = systemuser.Attributes["fullname"].ToString();

  • Suggested answer
    Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: User name oncreate plugin Postoperation

    If you're trying to retrieve the username you should query "domainname" which Is the schema name of username field.

    docs.microsoft.com/.../systemuser

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans