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 :
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

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans