Hi,
you can use some temp field and 2 automations: one runs when temp not empty and not match Current => move Current to Last move temp to Current.
Second automation - temp not empty and match Current => just clear temp.
I would create single automation, āwhen temp field not emptyā with script step. In script config, choose variables and name them after field values, then put this code:
1let rec={...input.config()}
2if (rec.temp!=rec.current) rec.last=rec.current;
3rec.current=rec.temp
4rec.temp=''
5output.set('record',rec)
6
it nice to use script inside automation, you donāt need to write code for load data/save data, just data processing part.
Note that if your fields are not text, some types canāt be cleaned by
rec.temp=''
. You should pass empty array or rec.temp=null
instead
Then add next step, Update record. Use values from script step according to fields.
Alexey_Gusev wrote:
Hi,
you can use some temp field and 2 automations: one runs when temp not empty and not match Current => move Current to Last move temp to Current.
Second automation - temp not empty and match Current => just clear temp.
I would create single automation, āwhen temp field not emptyā with script step. In script config, choose variables and name them after field values, then put this code:
1let rec={...input.config()}
2if (rec.temp!=rec.current) rec.last=rec.current;
3rec.current=rec.temp
4rec.temp=''
5output.set('record',rec)
6
it nice to use script inside automation, you donāt need to write code for load data/save data, just data processing part.
Note that if your fields are not text, some types canāt be cleaned by
rec.temp=''
. You should pass empty array or rec.temp=null
instead
Then add next step, Update record. Use values from script step according to fields.
Hi Alexey,
And first of all many thanks to pay attention to my post - really apricate this.
So I tried to not go to may case with the script that you provide till I will not understand the logic of it.
I created a table with fields as you name them in your script and tried to run a test - and from the fact that my script knowledge are ā0ā - I cant understand why it does not work. From the log I see that there are many error in the way how I tried to use your script.
Can you please help me how to handle this ! :pray: :pray: :pray:
ERROR
TypeError: Invalid arguments passed to output.set(key, value): ⢠value.current should be a JSON-serializable type, not undefined
at main on line 5
or
Property ātempā does not exist on type ā{}ā.(2339)
Veiw link: Airtable - Grid view
Mircea_Onciu wrote:
Hi Alexey,
And first of all many thanks to pay attention to my post - really apricate this.
So I tried to not go to may case with the script that you provide till I will not understand the logic of it.
I created a table with fields as you name them in your script and tried to run a test - and from the fact that my script knowledge are ā0ā - I cant understand why it does not work. From the log I see that there are many error in the way how I tried to use your script.
Can you please help me how to handle this ! :pray: :pray: :pray:
ERROR
TypeError: Invalid arguments passed to output.set(key, value): ⢠value.current should be a JSON-serializable type, not undefined
at main on line 5
or
Property ātempā does not exist on type ā{}ā.(2339)
Veiw link: Airtable - Grid view
Hi,
i suppose, you define input variables in a correct way (otherwise script would not reach output step).
it should be something like that

Well, i had some school programming backround very long time ago, before Windows era, and refused to understood all those object-oriented stuff from books. But itās easier to learn when you create something yourself. you are not supposed to be a developer, but to work in airtables, you need to get some basic things.
I think it fails because some of your fields type is not āstringā.
if you put text field value in some variable, like ātempā, you work with it directly.
some fields, like single select, multiselect, lookups, contain
arrays, itās like a box of ordered values [ āMonacoā, āParisā, āNiceā ]
or objects, the box of named values
in my example, ārecā is object. it may be described as
{current:āMonacoā, last:āParisā, temp:āNiceā}
You can refer to Field types reference for more info.
But right now, letās see what you got here:

try to paste this, to see your data types, and iāll tell you how to fix it
1let rec={...input.config()}
2output.set('last',typeof(rec.last))
3output.set('current',typeof(rec.current))
4output.set('temp',typeof(rec.temp))
5
Hi Alexey and thanks one more time for your time and patience.
Regrind work with airtbles - I know that I really should learn coding basics to use all features and to be able to build really powerful thinks - but to be honest I donāt know from what to start - it should be html or JavaScript?
About your kind last script suggestion - here what is the output from it:

Mircea_Onciu wrote:
Hi Alexey and thanks one more time for your time and patience.
Regrind work with airtbles - I know that I really should learn coding basics to use all features and to be able to build really powerful thinks - but to be honest I donāt know from what to start - it should be html or JavaScript?
About your kind last script suggestion - here what is the output from it:

Hi,
It seems like you didnāt define input parameters
here is a sample how it should be done.


After you defined them, you can begin write a script.
Parameters stored in read-only variable input.config()
If parameters are defined, you will see it as possible values, when typing variable name, like this

The rest are as described before
I donāt think youāll need html for it. Regarding JS, for now itās enough to read and understand some basic examples, like this
i supposed you already prepared first automation step, like this

if not, i would recommend to try and create some simple automation, without scripting at all, just get some value by trigger, put in to other cell. then, after you automation executed succesfully, you will better understand how to create the same, but using script after trigger, like on my last picture.