Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Can you add javascript directly to a Marketing form without having to create a landing page?

(0) ShareShare
ReportReport
Posted on by 177

Hi,

I know how to extend forms using javascript but so far it only looks like it works by adding the script to a landing page you create instead of directly to the marketing form itself in the HTML portion of the editor. Is this still not supported?

  • Suggested answer
    Stefano Sala Profile Picture
    Stefano Sala 15 on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    Hi Phil,

    I regularly use some Js code to add functionality to the Dynamics 365 marketing module. For example, I use it to give dynamicity or to create conditions for visibility of certain fields.

    As @Petr Jantač rightly pointed out, however, this definitely has limitations. To understand this, one must consider that the marketing module, and thus its code, is loaded in a specific order within the web page (creating a D365 marketing page or embedding the module in one's own web pages).

    In any case, you can test your customizations in real-time with tools such as Visual Studio Code or other tools that allow you to have a graphical preview online.

    Happy coding!

    Regards,

    Stephen

  • immilev Profile Picture
    immilev on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    No, you can't.  In Dynamics marketing forms are of 3 types, one of them being Landing Page. Technically, you can't have a marketing form without a page for it.

  • Verified answer
    Petr Jantac Profile Picture
    Petr Jantac on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    The javascript inside the HTML code of the form is supported. But there are some limitations, like certain events are triggered before the form markup is injected into a page, those won’t be available for the script added within a form.

    Thank you.

    Petr

  • pdr469 Profile Picture
    pdr469 177 on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    That still sounds like you have to add the script to a page later and not to the form itself. I’m looking for a supported way to add the code directly to the form within the form designer HTML.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    Hi pdr469,

    Add JavaScript code on your Marketing form and test this custom code using marketing pages.

    Add validations using JavaScript to Marketing form in Dynamics 365 | by Pooja Bhardwaj | Medium

  • pdr469 Profile Picture
    pdr469 177 on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    I’m aware of the article but the article doesn’t specify if you can directly modify the form itself with JavaScript. Does anyone know if that’s supported?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can you add javascript directly to a Marketing form without having to create a landing page?

    Hi pdr469,

    Please refer to the following documentation to know more about how to extended marketing form using JavaScript.

    Extend marketing forms using code (Dynamics 365 Marketing Developer Guide) | Microsoft Docs

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans