Help

Issue with batch script

671 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Ahmed_Elagami
7 - App Architect
7 - App Architect

Hello Folks,
The batch feature here works perfect and it creates 50 records in milliseconds and goes on till it finishes the total number of episodes ( EPS ), I have a tiny issue with the numerical calculation, it doesn’t work well with pattern adds to the date

So if you run this batch script to add 7 days to each date the result is not accurate

const importTable = base.getTable(“Titles”);
const importQuery = await importTable.selectRecordsAsync();
const episodesscheduletable = base.getTable(‘Episodes Schedule’);

const episodesScheduleQuery = await episodesscheduletable.selectRecordsAsync()
const episodesScheduleNames = episodesScheduleQuery.records.map(x => x.name)

let contactsToMake = ;

for (let record of importQuery.records)
{
let myDate = new Date();
let RowsToCreate=0;
RowsToCreate= record.getCellValue(‘EPS’) ;
myDate = new Date(record.getCellValue(‘Release Date’));

```
while (RowsToCreate>0)
{
    myDate.setDate(myDate.getDate() + 7);    
    await episodesscheduletable.createRecordAsync({
        "Release Date": myDate 
    });
    RowsToCreate = RowsToCreate -1   
}
```

}

The result
14/3/2021
21/3/2021
27/3/2021
3/4/2021
10/4/2021

So 14+7 = 21
21+7= 28 not 27

Is there something wrong with my code, I just want to add 7 to each date add up, but it’s not working properly, Do you have a quick fix for that?

Thank you guys for your continuous help and support. Appreciate your input
waiting for your reply.

0 Replies 0