Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Onclick event

(0) ShareShare
ReportReport
Posted on by 135

Hi all,

I want to attach a onclick event on a bit field. Is there a supported way to do this in crm 2013?

Thank you

Jan

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Onclick event

    Hi Jan,

    Yes- that's fairly straight forward to do. First you need to go to the customisation area and add a new web resource containing the javascript. You can either create this in notepad and upload the file or alternatively key it into CRM directly using the text editor.

    A sample of the required javascript is given here- in this case this custom function shows the myhideablefield form item if the mycheckbox field is checked and hides it if it's unchecked.

    // Show/Hide the hideablefield based on the mycheckbox field

    function myOnClickEvent() {

    var show = Xrm.Page.getAttribute("mycheckbox").getValue();

    if (show == true) {

    showField("myhideablefield");

    } else hideField("myhideablefield");

    }

    The you need to "wire up" the event handler to this custom function.

    To do this open the form containing the bit field you want to respond to.

    From the form editor click form properties.

    You will need to add the web resource file at the top of the events page where it says Manage libraries that are available in this form.

    In the events section at the bottom of the form locate your checkbox control and select on change. Finally you click add here and reference the newly imported web resource file and the name you gave the function (in the above example the function was called myOnClickEvent)

    That should get you up and running once you save and publish the customisation changes.

    I'd also add depending on your prior experience with javascript, for simple scenarios you could also consider using business rules to achieve the same results- these are basically a 'no code' approach which can be done all in the UI.

    Best of luck

    John

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Onclick event

    use onchange event.

    If my response is helps you, please mark as "Verified"

  • Verified answer
    ChrisC Profile Picture
    630 on at
    RE: Onclick event

    You change attach an onchange event to a boolean field if this is what you need.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,309 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,162 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans