Run Query Rules - InfoPath Dev
in

InfoPath Dev

Run Query Rules

Last post 09-16-2006 06:13 PM by mikeg. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 06-06-2006 07:47 AM

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11

    Run Query Rules

    I have a "Run Query" button with it's Action set to "Rules and Custom Code". I have a rule that if an ID field is blank, send a message like "You must enter a value!"

    The message works fine. The problem is, InfoPath runs the query anyway! I don't see any action available under Rule/Add Action to stop InfoPath from running the query with a blank field.

    Can someone tell me what I might be missing here? Thanks.
  • 06-06-2006 09:07 AM In reply to

    Hi Mike,

    I don't understand what you're wanting to do here. You have a rule that fires when a field is blank, but you don't want it to fire when it's blank?

    Please explain.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 06-06-2006 11:53 AM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    To put it more plainly: How do I prevent a query from running if a query field is blank or contains an invalid value?

    In the Run Query button properties, I have a rule that fires when the search criteria is blank or invalid. Now add an Action to send an error msg. This is working fine. But, after clicking OK on the msg dialog, InfoPath goes ahead and runs the query anyway!

    I don't see any Action available to stop the query from continuing other than "Open a new form to fill out" or "Close the form" which are both overkill. I hope this is more clear.
  • 06-07-2006 12:47 PM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    Maybe I'm just not explaining this very well...
  • 09-13-2006 08:07 AM In reply to

    at the bottom of the screen, there should be a button that says "stop processing rules when rule finishes" or something, make sure that is checked.
  • 09-13-2006 07:58 PM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    trufooser, "Stop processing rules when rule finishes" is indeed checked. That was the first thing I looked for. But I really appreciate the reply.

    The problem is not that subsequent rules are firing. My problem is the custom code still runs even when a rule fails. It may be a simple problem with my custom code, but I haven't had time to dabble with InfoPath since June!
  • 09-14-2006 04:31 AM In reply to

    I would try a small workaround.
    Create a new node (textfield control if you want). Set the default value to whatever you want (e.g NOT FILLED).
    Then if the user fills in the ID field with a valid value (by the way you can use data validation and the matches pattern option to check if the ID is valid) set your textfield to FILLED.
    Change your code or rules that the query only runs if the textbox value is FILLED.

    Does it make sense ?
    Listen to Motörhead cos they play Rock'n Roll :)
  • 09-14-2006 06:08 AM In reply to

    Hi Mikeg,

    As u have pointed out,even if the rule fails,the custom code still runs.Thats how it is.

    So in addition to ur rules,why dont u put a condition in ur code that lets the custom code to run only if the query field is not blank.
    something like...
    if(QueryField's value is not blank)
    {
    custom code comes here
    }

    or you could avoid using rules and accomplish everything using code itself.

    Regards,
    Abhishek
  • 09-14-2006 07:34 AM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    Okay, that's the perspective I was looking for. As a relative beginner, I wasn't sure how Rules interact with Custom Code. From what you guys are saying Rules never prevent custom code from running (unless maybe I specify some action like "close the form"). So, my custom code must check conditions independantly of or instead of using rules. I don't know why InfoPath functions this way, but I'll give it a try. Thanks.
  • 09-14-2006 10:10 PM In reply to

    Hi Mikeg,
    Just for your information,..Condition in rules dont prevent the underlying code from running.
    Using a rule, u can only ensure that the rules that follow do not execute.
    But to prevent the code from running,u need to do that in the code itself.
    Regards,
    Abhishek
  • 09-15-2006 02:02 AM In reply to

    • Stavi
    • Top 100 Contributor
    • Joined on 12-13-2005
    • Posts 95
    why dont you use two trigger fields? Put rules in trigger one, and code in trigger two

    trigger field one checks for blank ID, if blank says so and stops, if not blank change trigger field 2

    trigger field 2 runs code regardless
  • 09-15-2006 02:40 AM In reply to

    • Stavi
    • Top 100 Contributor
    • Joined on 12-13-2005
    • Posts 95
    oh, trigger field one should be your button not a field
  • 09-15-2006 06:05 PM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    These suggestions and clarifications are appreciated. I plan to try them out over the weekend. Sorry to say however, that I don't know what a "trigger field" is and I don't see anything in InfoPath help. Maybe I know the concept by another name. A simple example might help. Thanks.
  • 09-16-2006 06:25 AM In reply to

    • Stavi
    • Top 100 Contributor
    • Joined on 12-13-2005
    • Posts 95
    sorry i made the term "trigger field" up

    its a field which isnt realy used to store data, a hidden field that uses rules or code to perform tasks

    in this case, create a boolean field called trigger

    Then set rules on your button
    Rule 1, if ID is blank then inform user and stop rules
    Rule 2, if trigger is true set trigger false and stop rules
    Rule 3, set trigger true

    Then put your code on the trigger field and set it to run when ever trigger is changed

    If you are good at code then are probably easier ways to do it than this but i'm not good at code
  • 09-16-2006 06:13 PM In reply to

    • mikeg
    • Not Ranked
    • Joined on 05-23-2006
    • USA
    • Posts 11
    I see now. Very clever! If I have trouble with the IF statement I might try this idea. Thanks.
Page 1 of 1 (15 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.