Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40" - InfoPath Dev
in

InfoPath Dev

Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

Last post 01-11-2013 07:56 PM by varam4u. 24 replies.
Page 2 of 2 (25 items) < Previous 1 2
Sort Posts: Previous Next
  • 05-31-2012 07:53 AM In reply to

    • duugg
    • Not Ranked
    • Joined on 05-29-2012
    • Posts 13

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Hours_Total

    0 != xdMath:Nz(.) + xdMath:Nz(../my:Absence_Total)

    and

    40 != xdMath:Nz(.) + xdMath:Nz(../my:Absence_Total)

     -------------------------------------------------------------------------------------

    Absence_Total

    40 != xdMath:Nz(.) + xdMath:Nz(../my:Hours_Total)

    and

    0 != xdMath:Nz(.) + xdMath:Nz(../my:Hours_Total)

  • 05-31-2012 08:13 AM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Given the XPaths to your fields:

    Hours_Total XPath =       /my:myFields/my:Hours/my:Total_Hours/my:Hours_Total

    Absence_Total XPath =     /my:myFields/my:Absence/my:Absence_Total

    I think the correct expressions would be:

    Hours_Total

    0 != xdMath:Nz(.) + xdMath:Nz(../../../my:Absence/my:Absence_Total)

    and

    40 != xdMath:Nz(.) + xdMath:Nz(../../../my:Absence/my:Absence_Total)

     -------------------------------------------------------------------------------------

    Absence_Total

    40 != xdMath:Nz(.) + xdMath:Nz(../../my:Hours/my:Total_Hours/my:Hours_Total)

    and

    0 != xdMath:Nz(.) + xdMath:Nz(../../my:Hours/my:Total_Hours/my:Hours_Total)

    The XPaths are relative - so, for Hours_Total, it needs to be "how do I get from here to Absence_Total?" and for Absence_Total, "how do I get from here to Hours_Total?"

    More on XPath here.

    Hilary Stoupa

  • 05-31-2012 08:33 AM In reply to

    • duugg
    • Not Ranked
    • Joined on 05-29-2012
    • Posts 13

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Yes yes yes, that worked when the hours equal 40, Thank you! :)

     Now, when the total hours DON'T equal 40, I get this message here...

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

    This form contains validation errors. Errors are marked either with a red asterisk (required fields) or a red, dashed border (invalid values).

    Do you still want to send it?  YES/NO BUTTONS

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Can I instead, have it say something like "Total Hours do not equal 40", please fix before sending" with an OK button.

    Basically people tend to ignore dialog boxes and will just press whatever they need to force a message to go through. My way eliminates this.

    Can this be done?

     Thanks again so much for your help.

  • 05-31-2012 08:36 AM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    So, what are you doing when you get the message? Clicking Submit? Do you have Submit rules set up? Or is this some other button?

    Hilary Stoupa

  • 05-31-2012 08:41 AM In reply to

    • duugg
    • Not Ranked
    • Joined on 05-29-2012
    • Posts 13

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Ahh, yes I forgot to tell you that small detail.

     I have the form published to email recipients. They open up the email, fill out the form, type the email address it goes to and hit "Send". Once the "Send" button is hit is when I get the message I stated above.

  • 05-31-2012 08:52 AM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    I haven't used email forms much. I don't know if there is a way to entirely block Send - you may want to post a new question on that. I know that with a standard InfoPath form, you can't submit if there are validation errors - which is why I'd suggested validation. But it sounds like it doesn't block emailing.

    Hilary Stoupa

  • 05-31-2012 09:59 AM In reply to

    • duugg
    • Not Ranked
    • Joined on 05-29-2012
    • Posts 13

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Ahh, ok, At least it'll warn them.

    Thread solved and thanks!

  • 01-11-2013 07:36 AM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

     Hi,

    I have been trying to do similar kind of activity. 

    Scenario: There are two boxes to enter data .  ex: 40 in one box and 60 in another box. here i need to check that sum of both boxes should be 100. For this i tried above approach but not succeeded.

    my fields xpaths: 

    first field : -          /dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FiscalYear1SavingSharePercentage

    Second field :-    /dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FY2SavingsSharePercentage

     

     Could you please help me out this.

    Note: I am using infopath 2010 designer.

     

    Filed under:
  • 01-11-2013 08:49 AM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    So, your validation rule would have the condition that (/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FiscalYear1SavingSharePercentage + /dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FiscalYear1SavingSharePercentage) ! = 100, I think - why don't you post your form with what you've tried? You can attach it under the Options tab... You'd probably also want to add conditions to the validation that both fields are not blank, to avoid showing the error before the user enters the data.

    Hilary Stoupa

  • 01-11-2013 07:56 PM In reply to

    Re: Data Validation: Do not allow form to publish/send if the sum of two text boxes do not equal "40"

    Hi

    Thanks a lot for your help. It worked well.


    Regards

    KV

     

     

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