locked
Java Code Error: "warning: redeclaration of var controls" RRS feed

  • Question

  • Hi,

    My users are locked out of a field on their activity form.  It's not generating an error, but they need to be able to access the field. I ran the java script code through the online code checker and I received two 'warnings'.  They are below:

    100  
    101     for (var os in DependentOptionSet.options) {
    102      var Options = DependentOptionSet.options[os];
    103      var optionsToShow = Options.showOptions;
    104      /* Find the Options that corresponds to the value of the parent field. */
    105      if (ParentField.getValue() == Options.value) {
    106       var controls = ChildField.controls.get();
         =========^
         warning: redeclaration of var controls
    107       /*Enable the field and set the options*/
    108       for (var ctrl in controls) {
         ==============^
         warning: redeclaration of var ctrl
    109        controls[ctrl].setDisabled(false);
    110        controls[ctrl].clearOptions();
    111  
    112        for (var option in optionsToShow) {
    113         controls[ctrl].addOption(optionsToShow[option]);
    114        }

    Please let me know if you need to see any additional code to help me.

    Thanks -- Deb

    Thursday, May 21, 2015 6:51 PM

All replies

  • I could be wrong, but I think the word 'controls' may be reserved.  Just a guess, but see if naming that something else like oControls makes a difference.

    var oControls = ChildField.controls.get();

    for (var ctrl in oControls) {

    Thursday, May 21, 2015 7:51 PM
  • Hi,

    Change controls to oControls and ctrl to oCtrl. Check it may work.

    Also check your code whether you have already defined var controls  and ctrl if yes then this warning messages are correct.

    Thanks,

    Anand


    Monday, May 25, 2015 11:36 AM