Clear and disable controls using rules and cond. formatting? - InfoPath Dev
in

InfoPath Dev

Clear and disable controls using rules and cond. formatting?

Last post 01-16-2011 03:55 AM by praveenbattula. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 07-05-2007 09:57 PM

    Clear and disable controls using rules and cond. formatting?

    I have a form with quite a few controls on it, some of which are only used in certain circumstances.  If the user selects "None" from the first dropdown list, then I want to disable the following 4 dropdowns, 3 textboxes, and 3 checkboxes, and make sure that any value that they had gets cleared out. 

    Now I am using conditional formatting in all of those controls to disable them if the user selects "None", and that works fine.  The problem is that even though I set up rules in the first dropdown to clear out the values in those fields, they seem to get disabled, but the values remain.  Does the conditional formatting happen first, disabling them so that the value can't be changed by the rule, or am I just doing something wrong?  Is there a better way to do this?  Any help would be appreciated.  Thanks!

    - Kris
     

  • 07-05-2007 10:43 PM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    I would put all the controls in a section if you can, then you can just hide the section and do not have to set conditional formating on every field.

    You would need to have a rule on your drop down with an action for each field to set it to blank or 0 or the defualt value or whatever.  Setting the field's value should be independent of whether a control which is bound to it is visible or not. Make sure you do not have other rules or something that may override your changes.

  • 07-06-2007 10:00 AM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    Thanks for the quick reply.  Got a follow-up question for you now.  The form has two columns of controls on it in a table layout.  Is it possible to hide a section on the left without affecting the right-hand column?

    Also, I looked through all my controls and none of them have any rules associated with them.  Just conditional formatting for some that are to be disabled in some cases.  But the rule I used with the first dropdown just doesn't seem to be able to clear their values.  Very strange.  I couldn't find anything in the help about whether you can change the value of a disabled control.

    - Kris
     

  • 07-06-2007 10:07 AM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    I do not know of a way to hide columns, rows yes, columns no.  But to simulate you could hide the conrtols in the column but that would be work.

    So are you disabling the controls or hiding them?

    What are the values before?

    What are the values after?

    Are they the same?  Do you have default values for the fields?  You are using the set fields value action and setting them to blank?  Try puttin in another value other than blank as a test.

    Another debug trick I use sometimes is put a rule on one of the fields that is misbehaving, with no conditions so it fires each time the value changes and then have the action be to display an expression box with the field's value.  That way you should get a pop up with its value each time it changes and you can see if it is changing in the first place or changing and then changing back.

  • 07-06-2007 11:02 AM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    Clay Fox:

    So are you disabling the controls or hiding them?

    I'm just trying to disable them, don't really want to hide them, although there are a few that are hidden by default; for those I just want to make sure that they get cleared and stay hidden if the user selects "None" from the first dropdown. 

    Clay Fox:
    What are the values before?

    What are the values after?  Are they the same?  Do you have default values for the fields?

    What they're filling in on these forms is information about water-related devices.  They usually start out blank, but sometimes, if the user is creating a new device record based on an existing record, they may have values in them already.  There are four dropdowns that handle the selections for Manufacturer, Model, Serial, and Size.  The checkboxes (labeled as "Unavailable") are there to allow them to bypass fields that are otherwise required.  If they check the box, then the dropdown is no longer required.  If they select "Other" from the dropdowns, then a hidden textbox below the dropdown will become visible and be required.

    Clay Fox:

    You are using the set fields value action and setting them to blank?  Try puttin in another value other than blank as a test.

    Yes. I create the rule, set the condition, select the field, and leave the last box blank.  That didn't work.  When I tried changing the value to something else, it does work.  So the rule is firing and changing the value properly.  Now the question is what do I need to put in that second box for the value to make the dropdowns or textboxes blank, and to clear the checkboxes?  It looks like it's trying to set them to "" right now.  The dropdowns do have a blank row at the top of them, so it's a selection that's possible for those.

     - Kris
     


  • 07-06-2007 11:17 AM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    Yah for dropdowns you need to set them to a value that is in the list of options or they revert to the default. Is the blank row, often the Select... display value the default?

    Maybe instead of blank set them to unknown or not required and have that as an option?  I think you are fighting the nature of the dropdowns and that if the field is blank then they use the default option.  You may want to hide them instead of disable and have a message appear or something.

    Good Luck

  • 07-06-2007 12:26 PM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    The default value is blank, so the top row in the dropdown lists is blank.  The dropdown fields themselves can be submitted as blank too.  That works fine.  When I look at the datasource properties for the field, the default value box is blank, and the checkbox for "Cannot be blank" is cleared and grayed out.  So blank is the default and a legitimate value for any of the dropdowns.  I just don't know how to specify it in the set field value rule.  Leaving the box blank like it is in the datasource properties default value box doesn't seem to work.

    - Kris
     

  • 07-06-2007 12:36 PM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    If you have another field that is blank you could try setting it to the value of that field.

    Otherwise, as I said before, you could use a non-blank value such as Unknown or Not Required?

    I have never had a problem setting a field to blank before. So you are saying if the drop down has "Kohler" for the manufacturer and you set it to a blank value that it still has "Kohler" afterward? Another trick would be changing a field to text box as a test and playing with that and verifying it is a drop down issue or not.

  • 07-06-2007 01:10 PM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    Ok, it's working now.  I'm still not exactly sure what I am doing wrong, but I think it had to do with setting the checkbox value.  I think that that was failing and causing the rest of the actions to fail as well.  When I removed that action, the dropdown and textbox got cleared.  Sorry for taking up your time.  I'll keep playing around with it until I get the checkboxes working as well.  I hadn't thought of creating a blank textbox and setting the value equal to that.  That would probably work too.  I'm still pretty new to Infopath, and it's quite a bit different than other tools I've used.  But so far so good.  Thanks a lot for the help.

    - Kris 

  • 07-06-2007 01:17 PM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    Its all a learning experience and you have to tinker a lot and try things to really know how they work.

    One thing on your check boxes you have to give them a value for both checked and unchecked. They cannot be blank or they wont allow you to uncheck them by default. So you need true and false or yes and no or something.

    That could be your issue.

  • 01-16-2011 03:55 AM In reply to

    Re: Clear and disable controls using rules and cond. formatting?

    The same problem faced by me and here is the solution I came up with: http://praveenbattula.blogspot.com/2011/01/clear-and-then-disable-controls-in.html
    Filed under:
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.