Created
November 22, 2022 19:51
-
-
Save Przemocny/2016f6835df5b02546526a3364c43342 to your computer and use it in GitHub Desktop.
HRy LHA / Umowy / Etap 8 / Przygotowanie informacji do ankiet dla pracowników z umową i rachunkiem do podpisania
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getEntryFields(record, fields) { | |
return fields.reduce((sum, field) => { | |
sum[field] = record.getCellValue(field) | |
return sum | |
}, {}) | |
} | |
const registryTable = { | |
name: 'REJESTR UMÓW', | |
fields: [ | |
'MSC', | |
'LUDZIE', | |
'NIEPODPISANA UMOWA', | |
'NIEPODPISANY RACHUNEK', | |
'FORM #3 - LINKI DO NIEPODPISANYCH UMÓW', | |
'PODPISANA UMOWA', | |
'PODPISANY RACHUNEK' | |
] | |
} | |
async function fillFields() { | |
const table = base.getTable(registryTable.name); | |
const { records } = await table.selectRecordsAsync({ | |
fields: registryTable.fields | |
}); | |
const toUpdate = [] | |
for (const record of records) { | |
const copy = getEntryFields(record, registryTable.fields) | |
const haveSignedDocs = copy['PODPISANA UMOWA'] && copy['PODPISANY RACHUNEK'] | |
if (haveSignedDocs) { | |
continue | |
} | |
const haveUnsignedDocs = copy['NIEPODPISANA UMOWA'] && copy['NIEPODPISANY RACHUNEK'] | |
if (!haveUnsignedDocs) { | |
continue | |
} | |
const value = ` | |
Tutaj znajdziesz umowę i rachunek z poprzedniego msc, proszę o podpisanie cyfrowe i wgranie podpisanych dokumentów spowrotem w formularz! | |
Z góry dzięki! | |
link do niepodpisanej umowy: ${copy['NIEPODPISANA UMOWA'][0].url} | |
link do niepodpisanego rachunku: ${copy['NIEPODPISANY RACHUNEK'][0].url} | |
` | |
toUpdate.push({ | |
id: record.id, | |
fields: { | |
'FORM #3 - LINKI DO NIEPODPISANYCH UMÓW': value | |
} | |
}) | |
} | |
await table.updateRecordsAsync(toUpdate) | |
} | |
await fillFields() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment