Save the date! Join us on October 16 for our Product Ops launch event. Register here.
May 18, 2022 05:32 PM
Hey Community,
I need a hand to know if something is possible.
I can see using the automation and find records I’m able to achieve this for a single record but not multiple at once, is there something I’m missing or a simple script I could use to overcome this?
Any help would be appreciated.
Jul 31, 2022 07:26 PM
Hi,
With more fields, script is quite complex, with 2d-array, but in your case, where first value is static and third is constant, it should be smth like
Input:
1.request (insert request id from step 1)
2.vendors (insert your list of vendors from step 2, ‘make a new list of’ - ‘field values’ - …)
Script:
const table=base.getTable('Invites')
const {request,vendors}=input.config()
const create=ven=>({fields:{'RequestID':request,'Vendor':ven,'Status':'Invited'}})
const crt=vendors.map(create)
while (crt.length) await table.createRecordsAsync(crt.splice(0,50))
note that if your field type(s) in ‘Invite’ other than just text (for example, link or single-select, you should update your third line (press API, choose field types and see document and example)
Linter will highlight 5th line until you make it all correct.
Aug 01, 2022 06:38 AM
Thanks, Alexey! I think I’m getting there. The field type in the Invite table for Status is a Single Select. How would I change Line 3 to make this work correctly? I am getting an error that the field cannot accept the value.
Aug 12, 2022 02:36 AM
Sorry, I missed your reply.
I think you already found the answer, but for those who may read this topic later, for Single-select it will be
const create=ven=>({fields:{ 'RequestID':request,'Vendor':ven,'Status':{name:'Invited'} }})
note: if your single-select field has no ‘Invite’ choice, it will reject the update.
you should add it to existing choices before using, procedure described here:
Aug 12, 2022 05:13 PM
Thanks for getting back. I’m still working on this! The fields for RequestID and Vendor are linked fields back to those tables. How do I fix those?
Aug 12, 2022 06:50 PM
the cell value of link record
should be array:
[ {id: recXXXX},{id: recXXYY}, {id: recXXZZ}… ]
with any number of objects {id: recXXXX} , including 0 and 1
so, in your case:
const link=recID=>({id:recID})
const create=ven=>({fields:{‘RequestID’:[link(request)],‘Vendor’:[link(ven)],‘Status’:{name:‘Invited’} }})
Aug 14, 2022 11:59 AM
Thanks for your help, Alexey. I got some extra phone help on this and now it’s all set.