web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Plugin to allow this option

(0) ShareShare
ReportReport
Posted on by 365

pastedimage1604646271882v1.png

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;

namespace sample.sampl1
{
public class test : IPlugin
{
public object Service;

public Guid userId { get; private set; }

public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
Entity entity = (Entity)context.InputParameters["Target"];

//Entity Name

Entity userSetting = new Entity("usersettings");

//Guid Of the user record

userSetting.Id = userId;

//Attribute to set value of “Allow other Microsoft Dynamics 365 user to send email on your behalf”

userSetting["issendasallowed"] = true;

//Update the Record

Service.Update(userSetting);

}
}
}

i want to allow this option using plugin to trigger this email

I have the same question (0)
  • unbeatable Profile Picture
    365 on at

    while executing this code I am getting an error

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Can you please provide the screenshot that demonstrates step registration?

  • unbeatable Profile Picture
    365 on at

    can you please provide each and every step to register for this plugin

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    It was a question. You registered your plugin already and as you mentioned "you getting an error". So in order to help you - help me, please provide the screenshot of the step registration and error that you get.

  • Fubar Profile Picture
    2,761 on at

    not a direct answer regarding plugin, btu just in case you were not aware, it is possible to set user personal settings via Power Automate / Flow.  (we do it for the users TimeZone as users are always created for us based on the Server and we are technically in a different timezone to the instances server).

  • unbeatable Profile Picture
    365 on at

    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Query;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Remoting.Services;
    using System.Text;
    using System.Threading.Tasks;

    namespace UpdateOpportunityProduct
    {
    public class UpdateOpportunityProduct : IPlugin
    {

    public void Execute(IServiceProvider serviceProvider)
    {
    //Obtain the execution context from the service provider.
    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    if (context.MessageName != "Update")
    return;

    //Get a reference to the Organization service.

    IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    IOrganizationService service = factory.CreateOrganizationService(context.UserId);

    //Extract the tracing service for use in debugging sandboxed plug-ins

    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

    //Entity Name

    Entity userSetting = new Entity("usersettings");

    //Guid Of the user record

    Guid userId = default(Guid);
    userSetting.Id = userId;

    //Attribute to set value of “Allow other Microsoft Dynamics 365 user to send email on your behalf”

    userSetting["issendasallowed"] = true;

    //Update the Record

    service.Update(userSetting);
    }
    }


    }

    above is my following code and I have built it and trying to register as a post image so that each time when the owner is changed, through plugin it automatically allows that option to send email

    pastedimage1604986573964v2.png

    pastedimage1604986156772v1.png

    I am not getting the option to register 

  • unbeatable Profile Picture
    365 on at

    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Query;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Remoting.Services;
    using System.Text;
    using System.Threading.Tasks;

    namespace UpdateOpportunityProduct
    {
    public class UpdateOpportunityProduct : IPlugin
    {

    public void Execute(IServiceProvider serviceProvider)
    {
    //Obtain the execution context from the service provider.
    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    if (context.MessageName != "Update")
    return;

    //Get a reference to the Organization service.

    IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    IOrganizationService service = factory.CreateOrganizationService(context.UserId);

    //Extract the tracing service for use in debugging sandboxed plug-ins

    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

    //Entity Name

    Entity userSetting = new Entity("usersettings");

    //Guid Of the user record

    Guid userId = default(Guid);
    userSetting.Id = userId;

    //Attribute to set value of “Allow other Microsoft Dynamics 365 user to send email on your behalf”

    userSetting["issendasallowed"] = true;

    //Update the Record

    service.Update(userSetting);
    }
    }


    }

    above is my following code and I have built it and trying to register as a post image so that each time when the owner is changed, through plugin it automatically allows that option to send email

    pastedimage1604986655136v1.png

    pastedimage1604986655139v2.png

    I am not getting the option to register 

    [quote user="LA"]

    not a direct answer regarding plugin, btu just in case you were not aware, it is possible to set user personal settings via Power Automate / Flow.  (we do it for the users TimeZone as users are always created for us based on the Server and we are technically in a different timezone to the instances server).

    [/quote]

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans