Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

JavaScript Web Resource on Check Box field type

Posted on by Microsoft Employee

I have a Check Box field on a Quick Create Lead form and I want to perform some action when ever this field is selected(Checked) on OnChange Event. I have created a JavaScript Web Resource and it is performing the action whenever the check box field is selected(Checked), but the problem here is that it is performing that action even when the check box field is Unchecked. 

How to prevent that action while user is trying to Uncheck the check box field?   

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: JavaScript Web Resource on Check Box field type

    I applied the same function and it worked for me, thanks Radu

  • Verified answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: JavaScript Web Resource on Check Box field type

    Hi Sunny,

    This is expected behavior. The event handler is triggered on the on change event. Both checking and unchecking the box are considered on change events.

    To prevent the logic from being executed when the box is unchecked, you can add some extra logic inside the onchage method and verify the value of the field. If it is null simply return.

    Something llike

    function OnChangehandler(){

    var field = Xrm.Page.getAttribute("<your_checkboxfield">)

    if(field==false){

    return}

    else{

    //your logic here

    }

    }

    Hope this helps,

    Radu

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans