Rules not running when data retrieved from sql into IP - InfoPath Dev
in

InfoPath Dev

Rules not running when data retrieved from sql into IP

Last post 06-20-2013 09:30 AM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-20-2013 07:30 AM

    • JamesH
    • Not Ranked
    • Joined on 06-20-2013
    • Posts 5

    Rules not running when data retrieved from sql into IP

     Hi,

    I have a IP 2010 web browser form, within this form I have a number of checkboxes, set as Boolean fields, upon selecting a specific checkbox a corresponding section is displayed.

    This as it is works fine, however the form itself has 3 main views, each of these views use the same fields for the checkboxes & sections, but I have a need to cascade what is displayed. So on view 1, only the sections corresponding to the checkboxes selected on this view will display, on view 2 only the sections corresponding to the checkboxes selected on views 1 & 2 will display etc.

    I have a hidden text field which is automatically set to the name of the current view when the corresponding checkbox is checked (true), this occurs on the field changed event handler, then on each section I have a formatting rule set;

    If checkbox1 is equal to FALSE, OR checkbox1 is equal to TRUE AND Section1 is not equal to VIEW1 hide section.

    Before initial submission this works perfectly on the form, however I'm finding that if I'm opening an existing forms data from the SQL DB, then only the, If checkbox1 is equal to FALSE portion of the rule is actually running, it appears to be ignoring the other clauses. As a result all sections for the checkboxes selected are appearing on every view.

    Is there anything I should be aware of which may prevent more than 1 formatting rule from running on forms opened with XML data from an external data source?

    Just for your information, I'm running the InfoPath2010 forms within SharePoint 2010, all web services used to submit & retrieve data are stored within udcx files in data connection libraries & they're using secure store services to access the web services.

    If you need any other information, or what I have written is not clear, please let me know. Any help would be much appreciated!

    Thanks,

    James 

  • 06-20-2013 07:38 AM In reply to

    Re: Rules not running when data retrieved from sql into IP

     Hi - so, are you storing all this data that you are using for formatting? What do you mean by "... opening an existing forms data from the SQL DB"? I'm guessing that you are querying for data from the SQL DB into your template, but that the fields you are using for your formatting logic aren't being saved, so are back to blank or their default (like false)...

    Hilary Stoupa

  • 06-20-2013 07:45 AM In reply to

    • JamesH
    • Not Ranked
    • Joined on 06-20-2013
    • Posts 5

    Re: Rules not running when data retrieved from sql into IP

     Hi Hilary,

    Thanks for the quick response.

    All the fields which are used to format these sections are being passed into the database & stored within an XML field in the table, it's this XML field that is being retrieved & the innerXML of the form is being set to the innerXML of the field retrieved from SQL, so they are all being stored within the DB.

    I am passing the entire forms xml back to the DB.

    Thanks,

    James

  • 06-20-2013 07:50 AM In reply to

    • JamesH
    • Not Ranked
    • Joined on 06-20-2013
    • Posts 5

    Re: Rules not running when data retrieved from sql into IP

    One other thing, I have also checked the xml stored in SQL & the field storing the view in which the checkbox is selected is not changing as I'm changing views, meaning that they would all be the same, it is referencing the correct view for the selected checkboxes

  • 06-20-2013 08:01 AM In reply to

    • JamesH
    • Not Ranked
    • Joined on 06-20-2013
    • Posts 5

    Re: Rules not running when data retrieved from sql into IP

     This may be completely wrong but I have a feeling that as I have my hidden field recording the view name on the event handler for field on change, when I go to open an existing form, I am starting with a blank form on a different view, this form is calling a different web service to retrieve a named value pair for the forms name & ID within SQL, which is displayed within a drop down to select from, then once a load form button is clicked this retrieves the xml from the row with the ID from the named value pair. I'm thinking this could in itself be considered a field change event, as it's going from blank to viewName & is defaulting each of the selected checkboxes to view1

  • 06-20-2013 09:22 AM In reply to

    • JamesH
    • Not Ranked
    • Joined on 06-20-2013
    • Posts 5

    Re: Rules not running when data retrieved from sql into IP

     Ok, that was right. For anyone else who ever comes across this, the following code snippet can be placed within your onchange event to check the values against the cached value, so only updating if there is a difference between the 2;

    string memberVar = FormState["_memberVariable"] as string;
    if (!string.IsNullOrEmpty(memberVar) && memberVar == e.OldValue)

    {
            return;

    }

    else if (checkbox1 == "true" && memberVar == e.NewValue)

    {

            hiddenField.SetValue(this.CurrentView.ViewInfo.Name);

    }


     

  • 06-20-2013 09:30 AM In reply to

    Re: Rules not running when data retrieved from sql into IP

     Wonderful - glad you were able to track down the issue.

    Hilary Stoupa

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