Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Any user can send email in D365 setting 'From' to a shared mailbox

Posted on by 25

Users send emails from D365 both from themselves and from a shared mailbox by updating the 'From'
This shared mailbox is setup as a queue which has now been set to Private and specific members added.

The mailbox has been Approved, Tested and enabled

The problem though is that any user can change the 'From' in this shared mailbox and then send a mail
We want to be able to restrict who can do this.

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi

    Suggested JavaScript approach is one way to go about it.

    If you wanted to make sure the system does not send the email at all if the from should not be changed to particular user or queue, you can create a real-time workflow that triggers on (before) status change of the email record. Check the from field and the modified by user and if you think the email should not be sent with that from, you can use Stop Workflow step with an error message so that system will display an error message to the user saying you cant send this email.

    Let me know if you need any screenshots or examples for this.

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi Marc,

    For first question:

    Yes, it'll only block From field when current user is not administrator or any specific user, but you could integrate this part of script with your own business logic.

    For second question:

    If you want to restrict user to select specific mailbox, you could execute script below when form onLoad.

    I've added comments for how it works.

    // execute this function when form onLoad
    function FromFieldRestriction() {
        // register onChange event to From field
        Xrm.Page.getAttribute("from").addOnChange(checkUser);
    }

    function checkUser() {
        // execute checking function when there is a selected value/mailbox in From field
        if (typeof Xrm.Page.getAttribute("from").getValue()[0] !== 'undefined') {
            var user = Xrm.Page.context.getUserName();
            // get selected mailbox name
            var mailbox = Xrm.Page.getAttribute("from").getValue()[0].name;
            // check whether current user is allowed to change mailbox
            isRestrictedMailbox(user, mailbox);
        }
    }

    function isRestrictedMailbox(user, mailbox) {
        if (user == 'userA') {
            // restricted mailbox array
            var restrictedMailboxes = ['mailboxA'];
            // check whether the selected mailbox is existed in restricted mailbox array
            var flag = restrictedMailboxes.indexOf(mailbox);
            if (flag != -1) {
                var alertStrings = { text: "You're not allowed to select this mailbox, please select aother." };
                var alertOptions = { height: 120, width: 260 };
                // open a CRM alert dialog and set From field to null
                Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(function () { });
                Xrm.Page.getAttribute("from").setValue(null);
            }
        }
    }

    Regards,

    Clofly

  • MarcJ Profile Picture
    MarcJ 25 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Thank you... so this will not prevent a user being able to send an email from their own id's, it will just stop them changing the From to another id ?

    Is it possible to also check what they are changing it to ie. I do not want userA changing From to mailboxA but they can change it to mailboxB ?

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi Partner,

    You could insert following script with getControl().setDisabled(true) function into your Email form to lock From field,

    just with your own business logic.

    function checkUser() {
      var user = Xrm.Page.context.getUserName();
      if (user != "MOD Administrator") {
        Xrm.Page.getControl("from").setDisabled(true);
      }
    }

    xxz.png

    Regards,

    Clofly

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans