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

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Verified answer
    ChrisC Profile Picture
    630 on at

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

  • Verified answer
    Community Member Profile Picture
    on at

    use onchange event.

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

  • Verified answer
    Community Member Profile Picture
    on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans