Exploding list items and store in variables

Hi,

I am searching a local data source via SKU and pulling row information into variables - SKU, Item, Price, Qty.
I concatenate these variables separated by a comma to create a CSV string and then store that in a variable. I then add that variable to the bottom of a list and display it in a List Viewer which serves as a shopping cart.

Once I have completed adding to the cart, I want to cycle through the list, and explode each line and save each component into variables which I then add to a Sales table.

My problem is that I cannot figure out how to explode the data in the list line item.

Remove the list [gear] block. That block makes anything to the right of it into a list. But your variable is already a list so that block is creating a list of lists which is generally a bad idea. There is almost never a reason to use that block except when initializing list variables.

I would use a single data source for these two operations rather than using a local data source for one and a list for the other. You can “flag” rows added to the shopping cart and then just display those.

@tatiang I am just using the List for display purposes so that as items are chosen they are added to the list as a CSV.

Once the sale is complete, I then want to explode the CSV, placing the data into variables which are then used to update a Sales table.

Can you give an example of that?

Once I get back to my PC in the AM

Are you familiar with object blocks yet?

This is what I am trying to achieve -

So it is the Checkout action that I am having problem trying to implement

I am looking for something that will do the equivalent of this -

This gets the row of information, adds it to a list, and when checkout is clicked creates rows on the sales table.

Edit: Added the list viewer to see current cart.

Thanks for the help so far.

There was a slight error in your last block (object should be rowOject and not j) and I also added a for each item so that the app iterates through the shopping listview variable and adds each item to the Sales table.

I think you better double check your code. Your variables might be different, but it was 100% working the way I did it. You are iterating through a list where J represents the current item. You are currently cycling through a list, but reusing the same variable (rowObject) without changing it.

1 Like

Correct - j is the current item for the count but the object with the properties is rowObject. Have checked and it is working fine - populating my sales table.

Great, I’m glad that worked out for you. If you have any other questions let me know.

P.S. I’m still baffled that your code is working like that. When you add a bunch of different items does it repeat the same item over and over in your table?

1 Like

Was obviously tired last night. The code was adding to the table but only the last item in the list but when used j but that didn’t add anything.

Haha, Understandable. The list needs to contain objects.
You can create two lists. One is for you to view, and the other is hidden and contains all the data - shoppingCart, listOfObjects, or whatever you want to call the variable list.

In my example above, when a user adds something to the cart it gets the product info, then adds a new property called “Quantity”, and adds that to the object list.
When you checkout it will extract the data from the objects and store it your table. Variable “J” will be the object currently being exported.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.