Automatically increment date in spawned page from date field in previous page
- February 9, 2020
- 1 reply
- 1501 views
I have generated a staff timesheet with a button that will spawn a each new page at page 1 (making it easier to find the current week). The previous week will then become page 2 and so forth. I'm happy that the hours worked, charge codes copy across to the new spawned page and values can be unique to other sheet fields.
The trouble I'm having is, I need the date in SunRow1 on the previous page (page 2) to increment by 1 day in the new spawned page (page 1) field named WeekBeginning1. So effectively Im trying to have a new week at the top of the document with an auto-populated date incremented from the sunday of the next sheet down. Then the fields MondayRow1 to equal Weekbeginning1, +1 TuesdayRow1, +1 WednesdayRow1, +1 ThursdayRow1, +1 FridayRow1, +1 SatRow1, +1 SunRow1 on the new sheet.
Script for spawn button is as follows:
// JavaScript to create duplicate pages from templates P1
var num_copies = 1; // Set the number of copies here
var T1 = getTemplate("Timesheet"); // Use the actual tempate name here
if (num_copies > 0) {
var oXObjT1 = T1.spawn({nPage:this.numPages-1, bRename: true, bOverlay: false});
if (num_copies > 1) {
for (var i = 1; i < num_copies; i += 1) {
T1.spawn({nPage:this.numPages-1, bRename: true, bOverlay: false, oXObject: oXObjT1});
}
}
}
Im guessing unique script needs to apply in the spawn script for the day fields above . Im at the extent of my limited knowledge of javascript.
