Oct 22, 2022 11:59 AM
Hello! I am new to scripting. I am trying to replicate the action that is being performed on the variable below:
“ :writing_hand: CREATE: Product Input”: [{id:
${inputConfig.productInputName[i]}
}],
for:
“ :writing_hand: ADD: Input Qty (Mass per Unit)”: [{id:
${inputConfig.InputQty[i]}
}]
But failing, I believe because InputQty is a string of numbers (but formatted as a string) and the receiving field is a number field. What is the best way to convert from string to number?
Oct 22, 2022 02:02 PM
Welcome to the Airtable community!
You can try parseInt() to convert a text string that looks like a number to a number.
But that might not be your issue. It looks like you are using the write format for a linked record field, not for a number field. To write to a number field, you just give the number, without the square brackets, curly braces, I’d, etc.
Your screen capture does not show the value for InputQty
. The value is collapsed in the top right panel. The console.log()
of the three records to create is also collapsed.
Oct 23, 2022 08:17 AM
Thanks so much!! I updated the format per your suggestion and it looks like we are moving in the right direction, but I am still getting an error and also looks like there are 9 objects being written in the console log (should just be 3 numbers, as you can see – rest are undefined). Any idea what might be going wrong?
Oct 23, 2022 09:32 AM
What is your level of experience writing code and what is your level of interest in learning to code?
It sounds like there are multiple issues going on here.
The issue with the field type not matching the value you provided depends on the actual field type. You can find the write formats for each field type in the scripting reference.
The issue with creating more records than you want is trickier because it isn’t clear how you are getting the quantity. It looks like the length of the productInput, but it isn’t clear how that value is set or what it is. Plus, the screen isn’t good at displaying nulls.