Skip to main content

Is script extension really working? I have an script without errors but is not making anything


Forum|alt.badge.img+2

Hi, i'm landing with airtable and so far loving it, but I'm not sure if scripts works like other environments...

I have a table record with a lot of blank values at ID column because is an exportation from another ddbb and it exports fields with multiple values as a record for each value. Usually in other apps I make a script for this that get the variable when exists the ID value and replicate it at the next empty records ID until it finds a non-empty value and updates the variable, and so on.

I made the script and don't seems to have any fail but when executing is not doing anything (also no error text):

// Define the table and select all records let table = base.getTable("Dashboard"); let query = await table.selectRecordsAsync(); let records = query.records; // Initialize the lastref variable let lastref = null; for (let record of records) { let currentDefaultCode = record.getCellValue("default_code"); let currentDefaultCodeNexus1 = record.getCellValue("default_code_nexus1"); if (!currentDefaultCodeNexus1) { // If the "default_code_nexus1" field is empty, set it to the value of the lastref variable if (lastref) { await table.updateRecordAsync(record.id, { "default_code_nexus1": lastref }); } } else { // If the "default_code_nexus1" field is not empty, update lastref with the current value lastref = currentDefaultCodeNexus1; } // Update lastref with the value of "default_code" if it is present if (currentDefaultCode) { lastref = currentDefaultCode; } }

Any ideas? 

3 replies

TheTimeSavingCo
Forum|alt.badge.img+28

Could you provide a read only link to a duplicated copy of your base with some example data, as well as some screenshots of what you'd like to happen in a before and after of the script having been run?  That would make it a lot easier to help you


Forum|alt.badge.img+2
  • Author
  • New Participant
  • 1 reply
  • June 10, 2024
TheTimeSavingCo wrote:

Could you provide a read only link to a duplicated copy of your base with some example data, as well as some screenshots of what you'd like to happen in a before and after of the script having been run?  That would make it a lot easier to help you


Hi and thanks for reply! I cannot share a copy, but I can provide a picture that I think will explain what I mean.


TheTimeSavingCo
Forum|alt.badge.img+28
danieltch wrote:

Hi and thanks for reply! I cannot share a copy, but I can provide a picture that I think will explain what I mean.


Ah, without a base to troubleshoot it becomes very difficult to help you with your issue, sorry!  Hopefully someone else will be able to assist you!


Reply