How to determine a field value based upon a series of check boxes... - InfoPath Dev
in

InfoPath Dev

How to determine a field value based upon a series of check boxes...

Last post 03-24-2009 03:16 PM by toro_mike. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 03-24-2009 09:49 AM

    How to determine a field value based upon a series of check boxes...

    I have spent a couple of days searching for a way to do the following with no luck.  Any help you folks can give would be most appreciated...

    I have a browser-based form on MOSS 2007 that has 5 sections of tasks that must be completed in order to give a percentage completed.  The check boxes are set to TRUE if checked and FALSE if empty.  Each section of check boxes represents 20%. 

    What I need is a separate field that is automatically updated with the correct percentage as the sections are completed.  When the user checks all of the check boxes in section 1, they get 20%, when they check all boxes in the next section they get 40% and so on.  No % credit is given if section 2 is filled in before section 1...

    So, as a general test, I created a read-only text field with a rule under Validation and Rules in the field properties.  The rule has a condition where BS_PercentToClose_1 is equal to TRUE AND BS_PercentToClose_2 is equal to TRUE and so on. 
    The expression code looks like this:
    my:BS_20/my:BS_PercentToClose_1 = string(true()) or my:BS_20/my:BS_PercentToClose_2 = string(true()) or my:BS_20/my:BS_PercentToClose_3 = string(true()) 

    The action is to set the field's value at 20.

    If I preview the form, and check the boxes, it does not set the value of the field to 20.  So, I changed it so if box 1 in section 1 was checked it should change the field to 20.  No good still.  I published the form and activated it just to make sure.  Same issue.

    This seems really straight forward, but I cannot make it work.  I'm open to any ideas out there!!

    Thanks!
    Mike

  • 03-24-2009 12:10 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    Hi!

    It sounds to me from your description that you have set the rule on the field you wish to have change. Rules fire when the field they are bound to changes, so your rule is waiting for your read only field to change.... which isn't going to happen.

    Instead, you could set rules on your checkboxes. When checkbox one is modified it would set the value of your read only field appropriately, same with checkbox 2, etc. The problem with this approach is that you'll have to set up quite a few rules and conditions for each checkbox, but I'm not sure there is any way around that.

    Give it a try -- set the rule on the checkbox fields instead of the field you want to have the total percentage in....

    Hilary Stoupa

  • 03-24-2009 12:35 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    Hi Hilary...  Thanks for that.  I agree that I definitely was putting it in the wrong place! 

    Now...  I placed the following expression on each check box in section 1:

    . = string(true()) and ../my:BS_PercentToClose_2 = string(true()) and ../my:BS_PercentToClose_3 = string(true()) ../my:BS_PercentToClose_4 = string(true()) ../my:BS_PercentToClose_5 = string(true()) ../my:BS_PercentToClose_6 = string(true()) ../my:BS_PercentToClose_7 = string(true())

    That adds the 20 to the appropriate text box.  When you clear one of the boxes, it stays at 20.  Is there a way to tackle that?  Shouldn't unchecking trigger the Rule again?

    Thanks a lot for your help! 

    Mike

  • 03-24-2009 01:14 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    When you uncheck the box, .=string(true()) won't be true anymore, because the field's value is now FALSE. So you will need to add another rule with a condition to handle for what you want the value to be if the field bound to the checkbox is false (I think you are going to end up with *lots* of rules!)

    Hilary Stoupa

  • 03-24-2009 01:20 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    Ah yes, makes sense.  It is looking like a ton of rules with a lot of propensity towards mistakes!  Thanks for the direction...  I'll see where it takes me and post any further questions here if they come up.  You have been extremely helpful and I really appreciate it!

    Mike

  • 03-24-2009 01:47 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    I can't help but wonder if there isn't an easier way. Is your form bound to a data base? Or created from scratch? If you started with a blank form, you might want to consider adding attributes to the fields w/ the checkboxes. The attribute could store a value and each checkbox field would have a single rule to modify the attribute value... then your 'total' field could sum up the attributes.....

    Hilary Stoupa

  • 03-24-2009 03:16 PM In reply to

    Re: How to determine a field value based upon a series of check boxes...

    I'm sure there is an easier solution.  I just haven't been able to find it...  The form does connect to a database, is extensive, and has been deployed for some time.  This is an add-on that I need to do.  The problem with adding values to the check boxes then adding them up is that one check box does not = 2%.  The person filling in the form only gets credit for a full 20%, 40% and so on.  That's why I am going down this road to begin with.

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.