Skip to content

Instantly share code, notes, and snippets.

@HeadStudios
Last active January 30, 2023 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeadStudios/98c8837c02a0fb8540e3e36333281945 to your computer and use it in GitHub Desktop.
Save HeadStudios/98c8837c02a0fb8540e3e36333281945 to your computer and use it in GitHub Desktop.
let inputConfig = input.config();
// Get the record ID from the input
var recordId = inputConfig['rec_id'];
let table = base.getTable("Touchpoints");
let fields = table.fields;
let view = table.getView("Callback List");
let query = await table.selectRecordsAsync();
let original = query.getRecord(recordId);
console.log(original.getCellValue('Email'));
const main = async (original) => {
let obj = {}
filteredFields.forEach(fld => {
switch(fld.name) {
case "Start Date/Time":
const startDate = new Date(original.getCellValue(fld.name))
startDate.setHours(startDate.getHours() + utc_offset)
const newStartDate = new Date(startDate.getTime())
newStartDate.setDate(newStartDate.getDate() + 1)
while (newStartDate.getDay() !== 1)
newStartDate.setDate(newStartDate.getDate() + 1)
const newEndDate = new Date(newStartDate.getTime())
newEndDate.setDate(newEndDate.getDate() + 5)
obj["Start Date/Time"] = newStartDate
break
default:
obj[fld.name] = original.getCellValue(fld.name)
}
})
await table.createRecordAsync(obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment