Add ID in Recurring Tasks Script
An Excel tutorial by Peter Kalmström
In
the demo below, Peter Kalmström enhances the Recurring Tasks
script that he has already used in the two previous demos.
Now, Peter wants to create a powerapp for the tasks that
are due today, and for that each task needs to have a unique
ID.
Power Apps uses ID numbers in the background to keep track
of changes and unique rows in the Tasks table (which is
the app's data source in this case). In the app creation
process, it is possible to allow Power Apps to generate
the ID numbers and add them to the table.
Peter prefers to create the ID column and its values himself,
as this gives him better control over the app and Excel
table. Therefore, he adds another column to the Tasks table
and modifies the Recurring Tasks script to create an ID
number for each task. He uses the millisecond that the task
instance was added to the Tasks table as its ID value.
All steps to give each task a unique ID number are performed
in Excel:
- Add a new ID column to the left in the Tasks table.
It should have Number format and not show decimals.
- Open the AddTasks script in Edit mode.
- Add code for ID column value after "TaskTable.addRow(null,["
in the Template class, AddAsTasks method: new Date().getTime().
This will get the millisecond included on each row in
the Tasks table.
Now, the whole AddAsTasks method looks like this:
public AddAsTask(WB:ExcelScript.Workbook){
const TaskTable:ExcelScript.Table = WB.getTable("Tasks");
TaskTable.addRow(null,[new Date().getTime(), this.Title,new Date().toISOString().substring(0,10),""]);
let NewDate: Date = new Date();
NewDate.setDate(NewDate.getDate() + this.Interval);
this.Row.getLastCell().setValue(NewDate.toISOString().substring(0,10));
}
To make sure that the button is really taking the new script,
Peter removes the old button and then adds the script with
a button to the workbook again.
|
 |
 |
Software that enhances SharePoint |
Kanban Task Manager
Visualize and co-operate on projects and tasks in SharePoint
and/or Outlook |
Pivot Explorer
Visualize and analyze list data in SharePoint |
Templates Manager
Find, use, manage and distribute Office templates in SharePoint |
Calendar Browser
Resource booking in SharePoint calendars |
|