Need help with a script for hiding fields

Posted on 2012-08-21
Last Modified: 2012-08-29
Hi Experts,

I used a script that I got help with on Experts Exchange to create the attached.

It works well except for the last part.

Once the record has been entered, when I go to reopen the record I want both fields to show if the vsc_billtoid field is ‘New Customer Please Add’. The only time it works is if I click the vsc_newbilltoinfo check box and then click it again. Otherwise, it doesn’t work when the form is reopened.

What did I do wrong? The original script you provided works perfectly and I thought I would be able to use it to create this one. I am not getting any error messages.
Question by:jlblanke
    LVL 27

    Expert Comment

    by:Chinmay Patel
    Hi jblanke,

    It is a known behavior of CRM. To override it you can use this article

    Let me know if you face any challenges.


    Author Comment

    Thanks for the reference! :)

    I added the registerToggle code (attached) to the form's OnLoad event. Now I am getting an error:

    There was an error with this field's customized event.

    Field: window
    Event: onload
    Error: 'vsc_newbilltoinfo' is undefined
    LVL 27

    Expert Comment

    by:Chinmay Patel
    don't modify the existing script and add it as a separate web resource and in the page_load


    registerToggle("c", "vsc_newbilltoinfo", "targetcontrolname");  

    Open in new window

    Replace targetcontrolname with appropriate value.

    Author Comment

    I created the onload based on your example and the link you gave me and am getting window onload error:

    The value of the property 'registerToggle' is null or undefined, not a Function object.

    The Microsoft Dynamics CRM Error Report indicated the error at Line 1: Expected identifier.

    I used the IE F12 debugger but there are no errors showing.

    Attached is my code.

    Accepted Solution

    Got it working. There was a conflict with another script.

    Author Closing Comment

    I did not need to use the registertoggle script. There was another script that was calling this field. I was able to modify the first script and delete the second.

    Featured Post

    Training Course: Android App Development

    This course will involve creating widgets, customize list view, grid view, spinners, etc. Creating applications using audio, video, and SQLite database. Ending with publication on Google Play.

    Join & Write a Comment

    Both jQuery and Mootools offer some nice, easy to use scripts. Mootools is best known for their interactive slideshows and jQuery for their menus, but both have many other uses as well.   jQuery is basically a toolkit with many DOM (http://en.wik…
    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now