Skip to main content

Notifications

Announcements

No record found.

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

How to set "Test" prefix to Subject of Test send emails to help identify them as a test emails

(0) ShareShare
ReportReport
Posted on by 90

Good day!

When we customize Marketing email, we test email by "Marketing email test send" ("Test sent" button).

We need to set "Test_" prefix to Subject of Test send emails to help identify them as a test emails.

For changing email Subject we added (standard) Subject field to Quick create form "Marketing email test send", but the Subject of sent email is from Marketing email Subject still.

How can we:


1) Automatically add prefix to email's subject when using Test send emails.


2) Manually change subject of email when we fill out Subject field on "Marketing email test send" phorm.

Thanks for your reply.

5736.png

  • cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: How to set "Test" prefix to Subject of Test send emails to help identify them as a test emails

    Hi Spiker,

    Could it work for you?

    Regards,

    Clofly

  • Spiker Profile Picture
    Spiker 90 on at
    RE: How to set "Test" prefix to Subject of Test send emails to help identify them as a test emails

    Thank you very much, Clofly Mao, for your reply. We will try this approach.

  • Suggested answer
    cloflyMao Profile Picture
    cloflyMao 25,202 on at
    RE: How to set "Test" prefix to Subject of Test send emails to help identify them as a test emails

    Hi Spiker,

    As we know, system will generate a "Marketing email test send" entity record in each time we send a marketing email.

    However, "Subject" you added is only the name of "Marketing email test send" entity instead of the subject field of Marketing email entity itself.

    5238.JPG

    The subject of test send email is from subject of marketing email, thus the only way to achieve your requirement would be by changing subject of marketing email when we editing quick create form.

    Please take my steps as reference:

    1. Create a JScript web resource then add code below to the file:

    var addPrefix = function (executionContext) {
      var formContext = executionContext.getFormContext();
      formContext.getAttribute("msdyncrm_subject").setValue("Test_");
    }
    
    var changeParentEmailSub = function (executionContext) {
      var formContext = executionContext.getFormContext();
      var testSubject = formContext.getAttribute("msdyncrm_subject").getValue();
      var id = getParameterByName("id", parent.location.href);
      var etn = getParameterByName("etn", parent.location.href);
      var data = {
        msdyncrm_subject: testSubject
      }
      Xrm.WebApi.updateRecord(etn, id, data).then(
        function success(result) {
          console.log(result);
        },
        function (error) {
          console.log(error.message);
        }
      );
    }
    
    var getParameterByName = function (name, url) {
      if (!url) url = window.location.href;
      name = name.replace(/[\[\]]/g, '\\$&');
      var regex = new RegExp('[?&]'   name   '(=([^]*)|&|#|$)'),
        results = regex.exec(url);
      if (!results) return null;
      if (!results[2]) return '';
      return decodeURIComponent(results[2].replace(/\ /g, ' '));
    }

    There are 3 functions:

    addPrefix: populate the subject field with prefix.

    changeParentEmailSub: update subject of marketing email to subject of "Marketing email test send" when we lose focus on the subject field.

    (Why the function will be executed at subject OnChange event?

    Because system will send marketing email immediately after we clicked "save" button before subject of marketing email get update by custom code.

    Thus we update the field at subject OnChange event to give enough time to make sure subject of marketing email can get update.)

    getParameterByName: get guid and entity name of parent marketing email in URL

    2. Add addPrefix function to OnLoad event of form.

    pastedimage1594868601307v1.png

    After enabled the function, also remember to check "Pass execution context.." option.(It is required for second function.)

    pastedimage1594868687017v2.png

    3. Add changeParentEmailSub function to OnChange event of Subject field.

    pastedimage1594868734204v3.png

    Result:

    Now the subject is added with prefix, we should change subject of marketing email back when it comes to formal campaign. 

    (Or you could create a marketing email record for only test purpose.)

    pastedimage1594869020801v4.png

    pastedimage1594869053792v5.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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans