Help

Re: Expanding on Creating Multiple Linked Records Based on Mumeric Field

372 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Adrian_Head
6 - Interface Innovator
6 - Interface Innovator

Hi @kuovonne,

I found your script in the below thread incredibly helpful – Thank you so much this is a game changer for me!

https://community.airtable.com/t/weekend-scripting-block-challenge-and-1-000-prize/28074/9?u=adrian_...

I’m curious if you might be able to help me make an adjustment to the script for a specific use-case which I think it broadly applicable to people needing to use a script similar to the one your created above.

I have translated my problem to match the verbiage in your Cake order example to make things more clear.

You can find the link to my example base here for your reference.

Context:

Right now the number of New Linked Records I am creating in my Cakes for Creation table is dependent on a Count Field which is adding up the number of Items linked in the “Cake Types” Field (See examples below):

Count Field Creation:
Screen Shot 2020-06-02 at 13.31.45
Example as Field:
Screen Shot 2020-06-02 at 13.30.39

In your example, rows created by the script in the “Cakes” Table are created based off the number of cakes in the “Orders” Table and then the user has to manually put in what cakes make up each order.

For example: the cakes in the Jackie Order are “unknown cakes” until the user would go like by line in each new cake and label it with it’s cake type (Like in the John Example).
Screen Shot 2020-06-02 at 13.02.41

Screenshots from my Example Base:
Unknown Cakes Created (In Orders Tab):
Screen Shot 2020-06-02 at 13.39.19

The Different Kinds of Cakes Making up the Order Types Table:
Screen Shot 2020-06-02 at 13.53.19

Problem:

  • The problem in my workflow is that I receive the many orders at a time in the form of a spreadsheet.

  • The upside is that each order is labeled with the kind of cakes that makes up that order (This is what I use to create the Count Field which is leveraged by your current Script).

    • Screen Shot 2020-06-02 at 13.40.40
  • The downside is that is that labeling the new newly created “Unknown Cakes” for each order is very time consuming when there are dozens of orders and hundreds of cakes:

    • Screen Shot 2020-06-02 at 13.41.27
  • Labeling the Cakes is very important because it allows me to see how many of each cake need to create in a given time period so I can track my work properly!

NOTE: Manually labeling each Cake created also feels redundant as that information is already in my data-set (or would be created by an Airtable Form for creating New Orders for example):
Screen Shot 2020-06-02 at 13.57.20

My Question

Would it be possible for you to indicate how the script might be modified so that each new Linked Row in the Cakes For Creation Table is automatically labeled to match the corresponding Cake Type assigned to the order?

This would mean that the going straight to a table that looked something like this:

  1. From the “Orders Table” (Sorry about the typo):
    Screen Shot 2020-06-02 at 13.46.39
  2. Cakes in the “Cakes For Creation” Table are automatically labeled with the kind of cake that needs to be created:
    Screen Shot 2020-06-02 at 13.46.21

Relevance:

I think this would be a widely applicable script for many in the Airtable community who find ourselves in a similar situation to @Sheryl_Baptista in the original thread.

I am happy to be happy to try experimenting with this myself, but I don’t have very much code experience and a little guidance of the strategy for doing this would be extremely helpful!

Thank you in advance for any help you are able to give @kuovonne !

2 Replies 2

I’m glad that you found my script helpful, but I can see how it does not quite fit your use case. The screen shots really help to show what you want.

In this case, I think that a slightly different base design would better serve your purpose. Notice that the {Cake Type} field in the [CAKES FOR CREATION] table is a text field, but if it were a linked record, you would have a junction table between the [Orders] table and [Order Types] table.

Also notice that in your current setup, it would not be possible to have multiple cakes of the same type in a single order. (This might not be a problem for your particular use case, but it could be for some people.)

It is possible to adapt the script so it that would create the records as you like. Instead of creating new records based on a number, the script would inspect the linked records in the {Cake Types} field, and for each linked record in that field, the script would need to create a linked records in [CAKES FOR CREATION] with the links to the same {Cake Type} (or put the cake type in the text field.

However, this change would requiring rewriting large sections of the script. You are welcome to experiment with my original script (adapting the script is allowed by the MIT License). However, if you do change the script, you should also adjust the header information to indicate that you have made changes, and what those change are.

You say that you don’t have very much code experience. If you understand the following, you should be able to make the changes yourself:

  • loops in JavaScript
  • array handling in JavaScript
  • how to read and write records using Scripting block
  • the read format and write format of linked records

If you do not feel up to making the changes yourself and are interested in hiring me to make the changes, please let me know.

Thank you for the quick response @kuovonne !

I will DM you presently!