Stop code running if rules are not met in a button - InfoPath Dev
in

InfoPath Dev

Stop code running if rules are not met in a button

Last post 08-23-2009 12:33 PM by RhysAZ. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-21-2009 01:36 PM

    Stop code running if rules are not met in a button

    Hi- I have a button with rules in it. I have code behind the rules. How can I stop the code from firing if certain rules are not met. Thanks.

  • 08-22-2009 03:12 AM In reply to

    Re: Stop code running if rules are not met in a button

    if the rules are met, place some particular value (say "RulesFired") in a fied (say "areRulesFired"), and in the code check for the value. if the "areRulesFired" field does not have value "RulesFired" dont execute the code.

     

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 08-22-2009 08:38 AM In reply to

    Re: Stop code running if rules are not met in a button

    Just so I think I understand you correctly, at the end of each successful rule place a "set the value of " the (newly added) field called "areRulesFired" to "RulesFired" text . Then the code would look for the "RulesFired" text in the "areRulesFired" field. And if it finds it, then the code runs. 

    If the "RulesFired" text is not in the  "areRulesFired" field, the code doesn't run. Is my thinking correct?

    And if it is, can you please give me an example of what the line of code would look like and tell me where to put that line of code, in the code (in the beginning or in the middle or at the end)?

    Thanks qazi_anis

  • 08-23-2009 03:03 AM In reply to

    Re: Stop code running if rules are not met in a button

    XPathNavigator xntemp = null;

    XPathNavigator xnDoc = null;

    xnDoc = this.MainDataSource.CreateNavigator();

    xntemp = xnDoc.SelectSingleNode("/my:myFields/my:areRulesFired", this.NamespaceManager);

    if ( xntemp.toString().equals("RulesFired"))

    {

    //write your code here

    }

    // If this does not solve the problem attach the xsn and the cs file and i will try to resolve it for you

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 08-23-2009 03:09 AM In reply to

    Re: Stop code running if rules are not met in a button

    if u have more than one rule. then u might consider option of appending some value to it

    suppose on firing of ur rule 1 set the value of (say areRulesFiredto1)

    on firing of ur rule 2 append (2) to it so that new value is (12)

    similar for all your rules

    and in the code just check if the value is equal to ("123..n")

    hope this solves the problem

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 08-23-2009 12:33 PM In reply to

    Re: Stop code running if rules are not met in a button

    Thanks qazi_anis. I'll give it a try and let you know how it turns out.

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