Code or rules priority ? - InfoPath Dev
in

InfoPath Dev

Code or rules priority ?

Last post 06-12-2007 09:22 AM by Greg Collins. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 06-05-2007 07:18 AM

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Code or rules priority ?

    I have a button with code (onclick event) and rule (query submit). Through vbs code I fill query fields, and with query submit rule I try to submit my query, but query appair to start before query fields are filled. There is a way to change priority execution or wait after fields are fill up? Thank you.
  • 06-05-2007 01:24 PM In reply to

    Re: Code or rules priority ?

  • 06-06-2007 12:21 AM In reply to

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: Code or rules priority ?

    Hi Greg,

    thank you for reply. My problem now is to submit a "query_rule" execution after queryfields fill up. Is there a way to submit from code the execution of a "query_rule" (with datafields fill up automation)? Also have you idea for another way to do this?

    Thanks in advance.

  • 06-06-2007 09:26 AM In reply to

    Re: Code or rules priority ?

    You have two options:

    1. Move all the code to rules. This might be possible if you are not doing anything fancy and just filling in the query fields.
    2. Move all the rules to code. This is probably easier and safer for a couple of reasons:
        a) Sounds like all you have is the query. This can be done in code by calling the Query() function on the data connection (search this site for examples).
        b) You can use try/catch to get better error handling than the yucky error message InfoPath provides if something goes wrong.

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

    • Raoul
    • Top 500 Contributor
    • Joined on 05-05-2006
    • Posts 32

    Re: Code or rules priority ?

    Hi Greg,

    thank you for your clear answer, but I have last question. If I use second option and call query() function from code, all datafields on my forms (I have 3 views of datafields) are automatically filled with data after query execution, or I can fill any single field (a lot of fields!) via code?

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

    Re: Code or rules priority ?

    Whatever fields you have bound to that datasource are going to be changed when you do the query. That's the nature of the beast. When you query, it returns a set of data. Any controls that bind to that datasource are going to be updated with that new set of data.

    If you don't want that to happen, then you need to have a separate data adapter to do your querying, and after the query has completed, copy over values from that datasource to the one your fields are bound to.

    Sorry if I'm not understanding something.

  • 06-11-2007 12:13 AM In reply to

    • YoungSC
    • Not Ranked
    • Joined on 03-01-2007
    • Australia
    • Posts 13

    Re: Code or rules priority ?

    Hi Greg,

    I know Microsoft usually seek feedback for improvements to their product and as an MVP, maybe it would have more pull coming from you (if you agree with the suggestion).

    What would be useful in a new InfoPath version would be to add a selection to the 'Action' drop down within the Rules wizard to include something like 'Run Code Event'.  You could define the sub routine name in a text box, write the sub routine, and then InfoPath would run it as part of a rule.

    It would certainly be more useful to some of the work I am doing and would provide greater flexibility for designers.

    Just a thought.

    Simon

     

  • 06-11-2007 09:49 AM In reply to

    Re: Code or rules priority ?

    I know that this is a common request for a future release of InfoPath. While I can't speak for Microsoft and I don't have any specifics as to what features they plan for their next release (nor would I be able to divulge them if I did), I do know that they are at least aware of the idea you mentioned. Whether such a feature is incorporated in the next release won't be known until they are ready to announce the new feature set (which won't be for quite some time).

    In the mean time, when you have timing issues like this where code must run first before rules, you will need to just ensure that the rule functionality is incorporated into the code. This will guarantee all items run in the correct order.

    Good luck.

  • 06-11-2007 05:34 PM In reply to

    • YoungSC
    • Not Ranked
    • Joined on 03-01-2007
    • Australia
    • Posts 13

    Re: Code or rules priority ?

    OK good to know.

    Thanks Greg

  • 06-12-2007 09:22 AM In reply to

    Re: Code or rules priority ?

    Great! Hopefully they will add it. I know I could definitely use that feature!
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.