Greetings all,
I’ve got a problem that I’ve been looking at for a while now regarding how to implement this workflow relating to an asset management and bookings solution.
Essentially, I want a table containing a few fields such as category, quantity, start and end dates, etc, as well as a relation to another table, which is a similar schema, except WITHOUT the quantity fields, and each row is a unique booking of a single asset.
The workflow should ideally work as such:
User enters asset category, start and end dates, and quantity. The automation then generates n entries in the asset booking table based on the quantity that was selected.
The creation of these entries is the easy part. I’ve successfully set up an automation with the following code (running from the “Hire requirements” table with the quantity field, into the “Outstanding allocations” table:
for (const entity of args.currentEntities) {
const quantity = entity['Quantity'];
for (let i = 1; i < quantity + 1; i++){
const createNewEntity = await fibery.createEntity("Outstanding Allocations", { "Hire Requirements": entity.id, "Piece No": String(i).concat(" / ", quantity) });
}
}
Where it gets tricky, is when a user wants to modify the quantity from this table. In this instance the automation will generate all the entries again. How would I allow for creation, modification and deletion of the associated records, based on the quantity field?