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,...
Answered

How to use javascript to set a field value conditionally for a Dynamics Marketing form

(0) ShareShare
ReportReport
Posted on by 183

Hi,

I'm building a form for a client and they have a requirement to populate certain checkboxes when another checkbox field is checked. I'm familiar with how to extend marketing forms with javascript but I just need some guidance on the actual function I would use to have it populate a checkbox field.

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi pdr469,

    For example, do you mean that you want to check the 'Do not email' when the 'Remember me' is checked in the following screenshot?

    pastedimage1658915073170v1.png

    You want to trigger the script when the first checkbox is checked or the form is submitted?

    Here is the doc about JS in marketing form, you could have a look:

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

  • pdr469 Profile Picture
    183 on at

    Hi Steve,

    It's a little more complex than that but yeah it needs to be when a checkbox is checked then go and check other checkboxes on the form. I'm already aware of that developer guide and I've been able to get some code to work but I'm stuck on what the actual statement is to check a checkbox field. I've done some Googling but haven't had much luck. I also have a requirement to hide some text and I can't figure out how to do that if it's not a field. It's just plain text a paragraph on the form.

  • Verified answer
    Petr Jantac Profile Picture
    Moderator on at

    Hi,

    You can use the form HTML editor to include some ID to the element wrapping the text you want to hide:

    pastedimage1662383890628v1.png

    Like I did in the example above. I added id called MyTextToHide. Form editor will not remove this ID from the HTML, so you can use the Javascript to modify this field on the fly.

    Thank you.

    Petr

  • pdr469 Profile Picture
    183 on at

    Thanks Petr. I ended up going with something similar for the solution!

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

#2
Satyam Prakash Profile Picture

Satyam Prakash 24

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans