Help with "shopping cart" made with repeating tables - InfoPath Dev
in

InfoPath Dev

Help with "shopping cart" made with repeating tables

Last post 01-26-2008 08:05 PM by aznative. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 01-24-2008 02:29 PM

    Help with "shopping cart" made with repeating tables

    Hello everyone.

    I am still very new to Infopath.  I am trying to create something similar to a shopping cart using repeating tables.

    Here is the basic breakdown:

    There are two parts to the form: 1 drop down box and the repeating table 

    The dropdown box has a list of part numbers.  The repeating table has fields for the part number, manufacturer, and price.  All of the data for this is stored in an Access database.

    A)  User selects a part number from a drop down box.
    B)  A rule is ran that populates the fields in the first row of the repeating table.
    C) The user hits "insert item" and chooses another product from the drop down list.
    D) User repeats this until they have added all the products they need.

     The problem I am having is that all of the fields in all of the rows update to match what is returned from the last selected part number in the drop down list.  I am not surprised by that.

     Sooo...is it possible to do what I am trying to do?  I need the previous rows to retain the information they had and not to update every time a new part number is selected.  Just from some various reading I've done I am guessing the current() function holds the answer, but when I try to implement that in any fashion the table doesn't populate at all...the fields all stay blank.

     Thank you for your help!

    Josh

  • 01-24-2008 09:41 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    What you need to do is rearchitect a bit.

    Have your repeating table but move the drop down selection within the repeating table and bind it to the part number field. Put it in the initial column where you might display part number anyway.  Setup the source to your secondary connection which queries all records in the Table.

     Then the rules on the dropdown which set field values will only effect the row it is within rather than all rows.

    So the user starts form. Selects a partnumber from the drop down, name might be easier, but whatever and once they select it the rest of the row it set with the data using filters.  Then they insert the next row and select from that rows dropdown, etc.

     A better way would be to use web services to query your database, that way you would not have to load the whole data but could query for each part number.  Also then you could save the form dat back to your database for storage and analysis.

    You may want to check out the Database Accelerator Package which is a installable, ready to use, set of web services to interact with your database without the need for code. Qdabra Database Accelerator Suite Version 2.1 - Developer

    Filed under:
  • 01-25-2008 12:21 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    Hi Clay,

    Thank you for the guidance on this.

    I recreated the form as you suggested.  I am having a small issue with it though.

    First, I am using Infopath 2003 SP2 if that is pertinent. 

     
    Let's say this is the table I am using in my Access database

    PN         MFG

    A11         Sony
    D55         HP
    X89          Dell

     

    I set up the form with a repeating table where the first field is the Part Number and the second field in the Manufacturer (don't worry...this will get more user friendly...right now I am still learning the basics).

    I made the Part Number field a drop down box.  On the first row, when the user chooses a part number, the Manufacturer field populates correctly.  However, it starts messing up after that.

    Examples:

    A) If the user choose A11 on the first row it correctly returns Sony.  However, on all rows following the first it always returns Sony no matter what Part Number is chosen.

    B)  If the user chooses X89 on the first row, it correctly returns Dell.  If the user chooses D55 on the second row, it correctly chooses HP.  If on the third row the user chooses X89 again, it does not return Dell...it incorrectly returns HP instead.  It'll continue to return HP on each new added row no matter how many times use choose X89 or D55...HOWEVER, if you choose A11 again it properly returns Sony, but after that, it only returns Sony on every new row the user adds no matter what Part Number is chosen.
           
     I'm sure I'm missing something simple here...

     Thank you again for your help.

     Also, thank you for the link to the Qdabra tools.

     
    Josh
     

  • 01-25-2008 02:23 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    Hi

    One thing you can try is the current() bit of code if you are using InfoPath 2003.  This behaviour does not seem to occur in InfoPath 2007 due to a redesign of the Object Model.  To add it in 2003, go into the rule that sets the MFG field where is says something like:

    where PN (in database) is equal to PN (on form).  In the left hand drop-down box click on the drop-down and select "the expression".  This will bring up a string of XML referencing.  You need to search for the "=" sign in the statement.  To the right of that is a string that starts off something like

    xdXDocument:get-DOM()/my:myFields/@PN 

    now we try the current function as follows: where @PN = current()/@PN.  Then check if it works.  If it doesn't then your form data may be relational so you have to include the path to the field so the line would be @PN = current()/My Table/@PN or even current()/My 1st Table/My 2nd Table/@PN.

    Keep trying until it works that should help 

    Adam Harding
    Wales
    UK
  • 01-25-2008 04:21 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

     Hi Adam,

    If I choose Edit XPath under the rule I am able to get the XML referencing you mentioned.  Here is what I get:

    xdXDocument:GetDOM("ProductList")/dfs:myFields/dfs:dataFields/d:ProductList/@MFG[../@PN = xdXDocument:get-DOM()/my:myFields/my:Parts/my:PN]

     I added the current() function like so:

    xdXDocument:GetDOM("ProductList")/dfs:myFields/dfs:dataFields/d:ProductList/@MFG[../@PN = current()/my:myFields/my:Parts/my:PN] 

    Now the MFG field comes up blank no matter which PN I choose.  I tried different modifying it slightly be doing

    = current()/my:Parts/my:PN]

    and

    = current()/my:PN]

    but in all variations the MFG still comes up blank. 

    Josh 

  • 01-26-2008 11:06 AM In reply to

    Re: Help with "shopping cart" made with repeating tables

    OK

    Are you using Office 2007.  If so the current function is applied invisibly and you do not need to specifiy in the operating model.

    Cheers 

    Adam Harding
    Wales
    UK
  • 01-26-2008 12:53 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    No I am using Office 2003...with Infopath 2003 SP2.

    Thanks!

    Josh

  • 01-26-2008 04:08 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    OK

    Looking again

    What I used to do in 2003 was set up the RHS of the expression to be '= current()/@PN'  and that would work fine.  As far as remember the /myPN didn't occur in the old object model in 2003 and only in 2007 hence my question.

    Cheers 

    Adam Harding
    Wales
    UK
  • 01-26-2008 08:05 PM In reply to

    Re: Help with "shopping cart" made with repeating tables

    Edit:  I thought it took care of it...but it didn't...I was just careless with my testing.

    Edit 2: Thanks Adam...I did get it to work.  I had to put the current statement on the left side of the = sign like so:

    xdXDocument:GetDOM("ProductList")/dfs:myFields/dfs:dataFields/d:ProductList/@MFG[current()/../my:PN = ../@PN]

    Josh

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