Sep 24, 2020 07:01 PM
Hi
I need to send text to a linked record field instead of the record id in the same way as if I paste text into the field or if I do it with integromat (smart links) or parabola (typecast: true) but from an airtable scriptig block.
recordsArray.push({
fields: {
"PID": formatted_date + " | " + (i+1) + " : " + record.getCellValue("PKEY"),
"production date": current_datetime,
"Group": record.getCellValueAsString("group"),
"Sku": record.getCellValueAsString("txtsku"),
"lr": record.getCellValueAsString("txtsku"),
"Product SKU": [{id:record.id}]
}
})
I was hoping I could simply do this…
recordsArray.push({
fields: {
"PID": formatted_date + " | " + (i+1) + " : " + record.getCellValue("PKEY"),
"production date": current_datetime,
"Group": record.getCellValueAsString("group"),
"Sku": record.getCellValueAsString("txtsku"),
"lr": record.getCellValueAsString("txtsku"),
"Product SKU": [{id:record.id}]
},
typecast: true
})
Is there a way I can call the API from a scripting block and then do it in the same way Parabola does it for example?
{
"fields": {
"inventory link":["{id}"],
"order code":"{order code}",
"sku":"{sku}",
"order qty":"{order qty}",
"subtotal price":"{subtotal price}",
"total price":"{total price}",
"order datetime":"{order datetime}",
"order number":"{order number}",
"variants: id":"{variants: id}"
},
"typecast": true
}
Sep 25, 2020 08:30 AM
Hi @Claire_Conza,
I don’t think that’s possible with the current scripting API. Are you wanting to do that in order to create new records by linking the text you want in the primary field of the new linked record?
I think you’ll have to work around this by either looking up the records from the other table first (if they already exist), and retrieving their ID’s to add to your recordArray, or else by creating the new records in the other table first (if they don’t yet exist), and saving the ID’s from that action to add to your recordArray.
It requires more code, but it’s the “stable” way to do it - it’s the way Airtable’s devs intended for this sort of thing to be done when they wrote the API.