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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Suggested answer
    cloflyMao Profile Picture
    25,210 on at

    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

  • Spiker Profile Picture
    90 on at

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

  • cloflyMao Profile Picture
    25,210 on at

    Hi Spiker,

    Could it work for you?

    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

Responsible AI policies

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

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
TAHER_El_Mehdi Profile Picture

TAHER_El_Mehdi 30

#3
Satyam Prakash Profile Picture

Satyam Prakash 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans