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

Subscription Center - Java Script

(0) ShareShare
ReportReport
Posted on by 140

Hello Community,

does anyone has a java script example for subscription center?

When the contact clicks "do not email" all subscription lists should be deactivated!

Thank you!

Best Regards

Jennifer

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

    Hi Jennifer,

    As per my understanding, you could try code below, run it at "afterFormLoad" event of marketing form. 

    1. Get id value of "Do not email" input field and subscription lists in HTML mode of marketing page.

    We can find that "Do not email" element block is named as "data-editorblocktype="Field-checkbox"" and subscription list element block is named as "data-editorblocktype="SubscriptionListBlock"" by system.

    6138.x11.JPG

    2. At change event of "Do not email", check whether the checked property of "Do not email"  equals to true,

    if yes, uncheck other checkbox fields.

    MsCrmMkt.MsCrmFormLoader.on('afterFormLoad', function () {
      document.getElementById("bddafd65-310b-4d51-91b4-d251a5002add").addEventListener('change', function () {
        if (this.checked === true) {
          document.getElementById("66021523-07dd-ea11-a813-000d3aa08990").checked = false;
          document.getElementById("6c80c140-dfe1-ea11-a813-000d3aa08990").checked = false;
        }
      })
    });

    If I checked the "Do not email", then all subscription lists will be unchecked.

    pastedimage1597817059768v1.png

    Regards,

    Clofly

  • Jenni221 Profile Picture
    140 on at

    Thank you very much!

    And where do i have to put this script? in the marketing form or in the standard marketing page?

    I use the standard subscription center?

    How do i proceed when we host it externally via iframe?

  • cloflyMao Profile Picture
    25,210 on at

    Hi Jennifer,

    We should put the script on marketing page.

    From my using experience, I always put it after end tag of body element.(And the script should be nested in script tag.)

    3223.JPG

    ---  How do I proceed when we host it externally via iframe?

    I am not so clear about what does "host it externally via iframe" mean.

    Could you share me more details about it?

    As per my understanding, do you mean the form is being hosted on an external website such as Wordpress?

    If so, as far as I know, some WP plugins might create an iframe element on page and custom elements would be put to the iframe.

    To handle such situation, we could:

    > If custom elements were actually put to iframe, then we need to paste form embedding script to web page directly without using plugin. 

    > If iframe is actually another web page, then we should put the script to that corresponding page.

    In a word, elements in iframe couldn't be accessed.(A more accurate statement is that we couldn't inject javascript into iframe.)

    Please kindly point out if I had misunderstood towards your question.

    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…

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 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans