Flows and Datastores

Can someone advise if what I am trying to do is possible with flows ?

I am trying to move some of the actions for reading and writing to datastores into a flow as my application is getting large and difficult to keep track of.

I want to insert data from a table into a data store on the click of a button, this works with an inline flow but I could do the same thing with an action. I wanted to create an independent flow so I could reuse it and separate the logic from the UI.

Inline flow - works

Independent flow - not working

I have created an input parameter for the flow that gets passed the $index value from the selected record in the table. I have tried all sorts of combinations and the flow just inserts blank records

Button click calls: flow_AddToCart.run({record_id: $index})
Flow runs the datastore insert record with a value of: tableRepeat1[$param.record_id].pc_Part_no
if i just write the $param.record_id to the data store it writes the correct index value I cannot get it to write any data from the table, what am I doing wrong ?

Thanks, Paul

Any ideas anyone ?

@Teodor Can you advise please, is this possible?

Hello,
So if i understand correctly - you have some repeat region on your page and you want to be able to copy a clicked/selected record data from this repeat to a data store component? And this should happen with the flow component (not via inline flow)?

yes

It’s possible to use the inline flow on button click, but you won’t even need to use flows for this. You can directly attach dynamic events > click > data source > upsert.
Using flow for only one action like that is a bit of overkill.

It’s actually possible with the flows component, but it must be added in the repeater - so you can access the data using the data picker. So, add the flow component inside the repeater. Still i think it’s a bit of an overkill to use flows for such a simple event.

Thanks, I will try adding through repeater. On it’s own it is simple event but I have some additional actions performed on the data so it just helps to keep the logic in one place.

1 Like

Hi there Paul…

I wasn’t able to quite follow your exact situation, but I’m wondering if this post I put up recently will help…

Best wishes,

Antony.

Hi Antony

Thanks, I had the database to datastore working and looking at your post I used the same method as you which is good as I’m never sure I am doing things the correct way.

In this instance I wanted to insert an individual record from a table into the datastore and perform some additional actions, I haven’t had chance to try Teodor’s suggestion but will see what happens.

I think flows have a lot of potential going forward so will be interesting to see what people do with them

Hi there Paul…

Glad to hear we are on the same hymn sheet… I just made up my method on the spot, so glad you were thinking the same way!

I’ve now set up a complete data store with lots of flows which mirrors my contacts table in the database and have it all working.

Here are a few things I have found out as I’ve used Flows and Data Stores:

  1. I’ve found it easier to represent booleans as numbers in a flow, similar to how they are represented in the database.

  2. You have to be very aware of the synchronous nature of thing executed in the flow and the asynchronous nature of those done outside via the run statement…

  3. I’ve found the assign statement isn’t much use at the moment. If you assign twice to the same variable then you have two of that variable to select when testing the value in a condition and don’t know which one to choose.

  4. Don’t change the name of your data store after the first name change or that gets a bit complicated.

Wappler are looking to fix items 3 and 4.

After realising those things, they are working well for me!

Happy flowing,
Antony.

Antony, that is not a quirk … i think i already explained you this. This is how the databases and javascript values work… not a bug, not a quirk, not an issue.

The rest of the issues you mentioned will be improved.

Hi there @Teodor

I am sorry if my use of the word “quirky” did not sound so good to you.

I think this is an example of how the meaning of words changes in different cultures… in England, if someone or something is quirky then it is a bit different but usually in quite a positive, fun kind of way.

I’ll change the message to use a different word!

Best wishes,
Antony.

1 Like

What I mean is that this is not Wappler specific, and that this is nothing to worry about.

Looks to me you are worrying too much about some small things, that don’t really affect your workflow :slight_smile:

You should apply the index to server action which is the source of table repeat. Something like sclist.data.query1[$index]