AnsweredAssumed Answered

Creating n new records in other table

Question asked by drweb on Jan 4, 2019
Latest reply on Jan 4, 2019 by drweb

Hi,

 

I have a table 'Recurring' with some fields :

- ID

- Start Date (must be a monday)

- End Date (must be a sunday)

- DaysOfWeek (Valuelist : Mo-We-Fr or Tu-Th-Sa)

- Number of Days (calculation : End Date - Start Date + 1)

- Number of Weeks (calculation : Number of Days / 7)

 

I made a realtionship with the table 'Appointments'.

 

Now I need to have script that does the following if I have the following values :

 

Start Date = 7 january 2019

End Date = 27 january 2019

DaysOfWeek = Mo-We-Fr

Thus : 21 days

Thus : 3 weeks

 

0. If DaysOfWeek = Mo-We-Fr

1. Go to table 'Appointments'

2. Create a record for every monday in the given dates

3. Create a record for every wednesday in the given dates

4. Create a record for every friday in the given dates

5. Else if DaysOfWeek = Tu-Th-Sa

6. Go to table 'Appointments'

7. Create a record for every tuesday in the given dates

8. Create a record for every thursday in the given dates

9. Create a record for every saturday in the given dates

 

Doing this, the expected result in the Appointments table should be the creation of 9 records :

Record 1 : Monday 07/01/2018

Record 2 : Monday 14/01/2018

Record 3 : Monday 21/01/2018

Record 4 : Wednesday 09/01/2018

Record 5 : Wednesday 16/01/2018

Record 6 : Wednesday 23/01/2018

Record 7 : Friday 11/01/2018

Record 8 : Friday 18/01/2018

Record 9 : Friday 25/01/2018

 

I hope my explanation is clear enough and I hope some can get me on the right track...

Kind regards,

Kurt

Outcomes