Repeat database inserts depending on select value

I have a data insert that I would like to repeat ‘X’ amount of times on either a daily (1) / Weekly (7) / Bi-weekly (14)
the quantity comes from a text input in the form and the other daily/week/bi-weekly comes from a select list.
I am guessing I would need to set a repeat up in the action sets for the amount of times.
But how would I add the frequency times eg plus 1 / 7 / 14 days
if anyone could point me in the right direction this would be great.

Thanks

The repeat step accepts numbers as expression. So you can pass a number to it, when you run your server action.

Is there a walk through or a visual tutorial on this @Teodor

Hello,
Which part of using a repeat and insert inside is not clear for you, so i can try to explain it?

Adding the amount of times for it to be repeated from the passed value from the select menu.

Well just use your POST variable as an expression in the repeat step …

Ok. So where would I add this on the repeat for the insert ??

Peter, you add this to the repeat, so that the repeat runs X times the insert step.

Ok let me fire up my laptop and grab a beer and I’ll have a look to see if I can get it working…
Cheers @Teodor

Hi @Teodor I’ve sorted the repeat out, thanks for the pointer.
However I also have a date that I want to add by frequency on the insert on the repeat.
For some reason this is not working, see image on how I’ve set it up

Which value is not inserting exactly, and what are you trying to insert?

As you can see the repeat works (it entered it 3 times which is what I wanted)
But as you can see by the date, they are all the same and they should not be.
On the page I have a select for the frequency (1, 7 or 14) depending no which the user selects I need the days adding on.
So for the example in the picture the dates should have been
2019-12-16
2019-12-17
2019-12-18

I hope that makes a little more sense

Which date is that? You have two date insert values on your first screenshot?
And where is the initial date coming from? Is it a form input?

sorry it is the first date, not sure why that is showing 2 dates. I did have a from - to date picker in there but I deleted that one

So do you have a form input, which you are using to select a start date, and then you want to increment the days with 1 for each of the next records?

correct, but from the increment needs to come from the posted select value (sd_feq) as it could be different for each event

Ok but does the INITIAL DATE come from a form input???

yes, its date and time by the way, not 2 dates.

<div class="col"><input id="inp_sd_start" name="sd_start" type="text" class="form-control" is="dmx-date-picker" timepicker="" format="DD MM YYYY HH:mm"></div>

Ok then just use the same expression for the repeat and in the insert step, where you insert the date do this:

  1. Select the POST variable, which returns the date
  2. Click the data formatter option
  3. Use the Date Add formatter
  4. Select days, then as a value select the $index returned by your repeat:

Screenshot_28

that’s all.

1 Like