Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Disabling sending an email from a contact form

Posted on by 10

We would like to disable sending emails from a contact form in Dynamics so everyone has to send email through Outlook.  We don't want to prevent Dynamics from sending users emails for tasks or workflows though.  Is this possible?

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Disabling sending an email from a contact form

    Hi KDillon,

    You could disable email form by javascript:

    function disableEmailForm(executionContext) {
    
      var formContext = executionContext.getFormContext();
      var formType = formContext.ui.getFormType();
      // Create new record form type
      if (formType == 1) {
        var controls = formContext.ui.controls.get();
    
        for (var i in controls) {
          var control = controls[i];
          if (!control.getDisabled()) {
            control.setDisabled(true);
          }
        }
    
        // Hide editor if you don't want see error.
        formContext.ui.controls.get()[5].setVisible(false);
    
        var alertStrings = { confirmButtonLabel: "I know", text: "Please send email by outlook.", title: "Notification" };
        var alertOptions = { height: 150, width: 250 };
        Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
          function success(result) {
            console.log("Alert dialog closed");
          },
          function(error) {
            console.log(error.message);
          }
        );
      }
    
    }

    It will disable all email form fields to prevent user editing it,

    7416.JPG

    even if user click send button, it will show notification that "The email must have at least one recipient before it can be sent."

    The only short is that after the editor be disabled, it will display error in editor content, 

    you could hide it(I've already added) with formContext.ui.controls.get()[5.setVisible(false); .

    Regards,

    Clofly

  • Suggested answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Disabling sending an email from a contact form

    Hi KDillon,

    I went into the Contact Form and chose to modify the "Social Pane".  I included all activities except for the Email activity from the list and it stops me from creating the Email on the form in the Social Pane.  I assume it will not show the emails in the list so not sure it does exactly what you would like...

    Screen-Shot-2019_2D00_10_2D00_30-at-5.03.36-PM.png

    Hope this helps!

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabling sending an email from a contact form

    Option 1: You can use the Ribbon Workbench to hide the Email button from the Contact Form.

    Option 2: You can deactivate the main forms of the email entity, this doesn't affect sending email from workflows. If you do this, you will need to create a new main form (that may be has everything hidden in it except a message saying use outlook please).

    None of the above options are perfect but If it was me, I will go with option 1.

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

Product updates

Dynamics 365 release plans