Compare main field to any repeating secondary fiel - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » Compare main field to any repeating secondary fiel Compare main field to any repeating secondary fiel Last post 10-15-2009 08:38 PM by Daniels. 8 replies. Page 1 of 1 (9 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 07-14-2005 08:06 PM wcotech Joined on 07-12-2005 Posts 34 Compare main field to any repeating secondary fiel Reply Contact Hey all,Is there a way to compare a field from the main data source to any occurence of a field in a repeating table bound to a secondary source? An example would be to set up a rule that says, if mainfield1 does not match "any occurence of" secondaryfield1, display "wrong"? 07-14-2005 11:34 PM In reply to Agni Jonnalagadda Joined on 12-15-2004 India Posts 617 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact Yes you can do this,When you compare a non repeating field with a repeating table field, InfoPath by default compares with all of the rows in the table. You dont need to write anything specific for that, its just regular condition.AgniInfoPathDev India Agni / http://www.ggktech.com 07-27-2005 07:07 PM In reply to wcotech Joined on 07-12-2005 Posts 34 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact Well Agni, I hope and pray that I am just missing something, but for some reason, everytime I set up the above scenario, the rule fails, thereby incorrectly compairing the main datasource field to any occurance of the field in the secondary datasource table. Any ideas???BTW, when I compare the main datasource field, value="1", to a field in the secondary datasource that has the same value for each record, in this case "1", the rule succeeds. 07-28-2005 05:05 AM In reply to smaur Joined on 06-17-2005 Posts 19 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact I experienced the same scenario. I think that all it takes is for one secondary data occurance to be unequal to the main source data for the test to fail. 07-28-2005 10:35 AM In reply to Agni Jonnalagadda Joined on 12-15-2004 India Posts 617 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact Let me try to explain you again,1. If your conditon is maindatasourceField1 = socondarydatasourceField2 In the above condition if maindatasourceField1 is equal to any one occurence of socondarydatasourceField2 then the output will be true.2. If your conditon is maindatasourceField1 != socondarydatasourceField2 This is apposite of the above condition, if maindatasourceField1 is equal to all occurences of socondarydatasourceField2 then you will have an output of false.If it is not equal to atleast one occurence of socondarydatasourceField2 then the output will be true.3. Third condition can benot(maindatasourceField1 = socondarydatasourceField2)This will give you an output of true if your maindatasourceField1 is not equal to atleast one occurence of socondarydatasourceField2.AgniInfoPath Dev India Agni / http://www.ggktech.com 07-28-2005 01:48 PM In reply to wcotech Joined on 07-12-2005 Posts 34 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact Hopefully we're both missing something simple here...I have an Access table, [Users], that has the following fields:[kingID][username][passsword]I have created both a main and a secondary data connection to the table [Users]. In my form, I placed the field, [q:username] from the main datasource. I also placed the field [d:username] from the secondary datasource. I have a button that has the following rule:[Main-q:username] is not equal to [Secondary-d:username], display "wrong" in a dialog box.There is also a second rule that says:[Main-q:username] is equal to [Secondary-d:username], display "right" in a dialog box.When I preview the form and click the button, I get a dialog box that says "wrong" no matter what I put in the [Main-q:username] field, whether the name matches one of the records or not. I never get a dialog box that says "right".Now according to your above post, if I enter a username in [main-q:username] that matches any returned record in [secondary-d:username], the second rule should suceed. The problem is that I don't get the results that you posted. 07-28-2005 03:40 PM In reply to Agni Jonnalagadda Joined on 12-15-2004 India Posts 617 Re: Compare main field to any repeating secondary fiel Mark as Not AnswerMark as Answer... Reply Contact [Main-q:username] is not equal to [Secondary-d:username], display "wrong" in a dialog box. is my second condition, that is the reason it is giving you "wrong" message. [Main-q:username] is not equal to atleat one [Secondary-d:username] so the condition is returning true as output, so your first rule executes.When you are creating the rule, check whether you have checked the checkbox to "stop processing rules after this rule finishes". If this checkbox is checked then the rule that follows does not execute. If you dint get above thing, just make your second rule to be the first one and check the result.Hope you understood this!AgniInfoPath Dev India Agni / http://www.ggktech.com 09-15-2009 11:09 PM In reply to Daniels Joined on 07-27-2009 Melbourne, Australia Posts 18 Re: Compare main field to any repeating secondary field Mark as Not AnswerMark as Answer... Reply Contact The article InfoPath - Update Repeating Elements/Nodes in a Secondary Data Source provides instructions and a JScript example (code included) to loop through repeating nodes in a secondary datasource. The function takes the value of the an attribute (name) in the repeating node, and the XPath to the field in the Main Data Source which contains the required value. The function loops through each node in the repeating element, testing if the value the "name" attribute for each node matched the required value. If the required node is found, the value of he node is then set to the value from the field in the main data source. This function can also be used to compare values in a repeating element from the main or secondary datasources, if the final part of the function which sets the required value is ignored. Blogs: SharePoint Admin & Dev - SharePoint and InfoPath DevelopmentWeb Development & Programming - Php, C#, .NET Framework, SEO TipsWebmasterHub.net - Free SEO, Webmaster Resources Filed under: Infopath 2003, repeating section, xml, InfoPath 2007 and Sharepoint, repeating elements, jscript 10-15-2009 08:38 PM In reply to Daniels Joined on 07-27-2009 Melbourne, Australia Posts 18 Re: Compare main field to any repeating secondary field Mark as Not AnswerMark as Answer... Reply Contact Function now available in both JScript and VBScript The example loops through the repeating "Field" elements inside the "Batch" and "Method" nodes of a CAML template. When the required "Field" node is found by matching the "name" attribute, the value of the node is set to the value of a field in the form's main data source (set by the user).Event handlers configured on form controls call the function provided to find and update the corresponding node in the Secondary Data Source with the required value after user makes a change to the value of the form control/field.The function is available in both JScript and VBScript.View the article: InfoPath JScript, VBScript - Update Repeating Elements/Nodes in a Secondary Data Source An explanation of how to implement the function in an InfoPath Form: InfoPath Code - Loop through data source - JScript, VBScript Blogs: SharePoint Admin & Dev - SharePoint and InfoPath DevelopmentWeb Development & Programming - Php, C#, .NET Framework, SEO TipsWebmasterHub.net - Free SEO, Webmaster Resources Filed under: VBScript, XML form data, InfoPatath JScript, InfoPatath Code Page 1 of 1 (9 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
The article InfoPath - Update Repeating Elements/Nodes in a Secondary Data Source provides instructions and a JScript example (code included) to loop through repeating nodes in a secondary datasource. The function takes the value of the an attribute (name) in the repeating node, and the XPath to the field in the Main Data Source which contains the required value.
The function loops through each node in the repeating element, testing if the value the "name" attribute for each node matched the required value. If the required node is found, the value of he node is then set to the value from the field in the main data source.
This function can also be used to compare values in a repeating element from the main or secondary datasources, if the final part of the function which sets the required value is ignored.
Function now available in both JScript and VBScript
The example loops through the repeating "Field" elements inside the "Batch" and "Method" nodes of a CAML template. When the required "Field" node is found by matching the "name" attribute, the value of the node is set to the value of a field in the form's main data source (set by the user).Event handlers configured on form controls call the function provided to find and update the corresponding node in the Secondary Data Source with the required value after user makes a change to the value of the form control/field.The function is available in both JScript and VBScript.View the article: InfoPath JScript, VBScript - Update Repeating Elements/Nodes in a Secondary Data Source
An explanation of how to implement the function in an InfoPath Form: InfoPath Code - Loop through data source - JScript, VBScript