Skip to main content

Notifications

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

Set User personal settings on Create of "systemuser" entity through plugin

Posted on by 335

Hello All,

we have requirement where we want to create new user(systemuser) over there  on create(plugin) of it we set it's personal settings

2068.Untitled1.png

using plugin.
 

is there any reference then please share.

Thanks & regards,

yash

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Set User personal settings on Create of "systemuser" entity through plugin

    Hello,

    Did you do it sync or async? Try to use async.

  • Yash Trivedi CRM Profile Picture
    Yash Trivedi CRM 335 on at
    RE: Set User personal settings on Create of "systemuser" entity through plugin

    Hy Andrew,

    i have tried the same  i have applied the code in my plugin on Create message(Post-Operation) of systemuser entity but iam getting error when creating user...

    Exception Message: usersettings With Id = c8afd388-e471-eb11-a812-000d3a151567 Does Not Exist

    ErrorCode: -2147220891

    HexErrorCode: 0x80040265

    ErrorDetails:

                  ApiExceptionSourceKey: Plugin/SetUserPersonalSettings.SetUserPersonalSettings, SetUserPersonalSettings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fa59fef0d5af8bba

                  ApiStepKey: 0e33c685-dd70-eb11-a812-000d3a151567

                  ApiDepthKey: 1

                  ApiActivityIdKey: c27ac0bc-12ef-4b4e-9658-78cc26cec13a

                  ApiPluginSolutionNameKey: Active

                  ApiStepSolutionNameKey: Active

                  ApiExceptionCategory: ClientError

                  ApiExceptionMesageName: IsvAborted

                  ApiExceptionHttpStatusCode: 400

    HelpLink: go.microsoft.com/.../

    TraceText:

                  [SetUserPersonalSettings: SetUserPersonalSettings.SetUserPersonalSettings]

                  [0e33c685-dd70-eb11-a812-000d3a151567: SetUserPersonalSettings.SetUserPersonalSettings: Create of systemuser]

                                  flag 1Settings Updated on Create message c8afd388-e471-eb11-a812-000d3a151567

    and here is my code::::

    if (contextPlugin.MessageName == "Create")

                       {

                           Entity systemUser = (Entity)contextPlugin.InputParameters["Target"];

                           if (systemUser.Attributes.Contains("systemuserid"))

                           {

                               tracingService.Trace("flag 1Settings Updated on Create message " + systemUser.Id);

                              Entity updateUserSettings = service.Retrieve("usersettings", systemUser.Id, new ColumnSet(true));

                               // Entity updateUserSettings = new Entity("usersettings", systemUser.Id);

                               updateUserSettings["issendasallowed"] = false;

                                   updateUserSettings["autocreatecontactonpromote"] = 0;

                                   updateUserSettings["incomingemailfilteringmethod"] = new OptionSetValue(1);

                                   service.Update(updateUserSettings);

                                   tracingService.Trace("Settings Updated on Create message "+ systemUser.Id);

                            }

                          }

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Set User personal settings on Create of "systemuser" entity through plugin

    Hello Yash,

    There are a few references available:

    community.dynamics.com/.../setting-default-personal-settings

    translate.google.com/translate

    But general direction:

    1. Create the plugin that handles "Create" message of "systemuser" entity.

    2. Update "usersettings" entity with values you want to be set "by default".

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans