Following Leoâs announcement I thought it would be interesting to look at automating his Payslips example.
What I am going to show here is currently in beta and I maybe shouldnât be showing it but I think it is just too good not to.
We need to be able to create the payslip record and then automatically share the record with the correct person on the correct date so that payslips can be prepared in advance.
For this demo, I have created two apps:
- The Payslips app:
- A people app:
In our Payslips app, we build an automation:
- We trigger on a set day of the month
- We need our Tape API key for this automation as it is still in Beta.
- Search the Payslips app for all the payslips that are due to be published
- Get the related personâs records
- The complicated bit happens now in the script block
We need to get the relevant personâs email address for each of the payslips and this was the easiest way I could think to do this without loops, although there could be a different way.
- We need our two collections into one.
- we need our inputs formatted in a certain way so we build a JSONata evaluate string to do that this is where the merging of the two collections comes in the tricky part is getting the relevant email address from the related record. When a record in your collection has a related field Tape gives you the related record ID and a title which is what is displayed in the related record box on the record:
but we need the email address to do that we use this:
"email": people[record_id = $v.fields[field_id=519428].values.value.record_id].fields[field_id=519424].values[0].value,
What we are doing here is first of all finding the relevant âpersonâ via the record_id that matches the one given in our Payslip record person relation field once we have the relevant person we extract the email address and add it to our Inputs
3. This part runs our evaluation and puts our new object in a variable to be used in a bit it ends up looking like this:
{
"inputs": [
{
"record_id": 130458479,
"add_permissions": [
{
"email": "fred@jmc.tools",
"permission_level": 2
}
]
},
{
"record_id": 130167551,
"add_permissions": [
{
"email": "jason@jmc.tools",
"permission_level": 2
}
]
},
{
"record_id": 128371451,
"add_permissions": [
{
"email": "elara@jmc.tools",
"permission_level": 2
}
]
}
]
}
- we set our API Key
- we use the new
batchupdatePermisions
to set the permissions
Other use cases of this could be a support desk record where you only want the specific user seeing the record, a Staff memberâs record where they can update their address etc. and I am sure many others.
It is worth noting that If you are sharing one record at a time for example the support call record this is far simpler as you can get the related record details for a single record which gives you access to the email address directly.