Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

How to add to record instead of overwriting?

Solved
Jump to Solution
186 2
cancel
Showing results for 
Search instead for 
Did you mean: 

My record has a field that's named  'Automation history' which is where i want my scripts to keep a log whenever it does some changes, i keep this to identify errors etc. But the issue is that it get's replaced, is there any way to .push that value there instead of overwrite? All the other code i want to keep as is.

This is my code:

  let createOpportunity = await tableOpportunities.createRecordAsync({
    'Opportunity Name': orgName,
    'Organization number': orgNumber,
    'Company Type': orgType,
    'Foretaksregistret': orgRegisterDate,
    'Kommune': orgKommune,
    'Postnummer': orgPostNummer,
    'Automation history': "Record created at " + yyyy + '-' + mm + '-' + dd + " , fetching infomation from this link: " + opportunityGenerator + "\n "
    });

 

1 Solution

Accepted Solutions
Greg_F
8 - Airtable Astronomer
8 - Airtable Astronomer

Hi @Ruben_Rossvold ,

Your code  seems to be creating a new record. If you would like to append to it some information you could do it this way: 

 


  let updateOpportunity = await tableOpportunities.createRecordAsync(record.id,{

    'Automation history': "Update to record automation history: " + updatevalue +"\n" + record.getCellValue("Automation history")
    });

This update will replace the value of 'Automation history' with new value, but you are also attaching the old value to it so, it will keep the historical content.

 

Let me know if this helps?

See Solution in Thread

2 Replies 2
Greg_F
8 - Airtable Astronomer
8 - Airtable Astronomer

Hi @Ruben_Rossvold ,

Your code  seems to be creating a new record. If you would like to append to it some information you could do it this way: 

 


  let updateOpportunity = await tableOpportunities.createRecordAsync(record.id,{

    'Automation history': "Update to record automation history: " + updatevalue +"\n" + record.getCellValue("Automation history")
    });

This update will replace the value of 'Automation history' with new value, but you are also attaching the old value to it so, it will keep the historical content.

 

Let me know if this helps?

Heh grabbed the wrong line there sorry, the above one is the one which is creating the record, and this below calls another api to update some of the created records one week later.

    await tableOpportunities.updateRecordAsync(record, {
        'Owner': personNavn + " " + personEtternavn,
        'Automation history': record.getCellValue("Automation history") + yyyy + '-' + mm + '-' + dd + "\n " + "Added owner name \n"
    })
}

 I did like you wrote and it worked, thanks so much!