Skip to main content

I have a script that is using a repeating group to batch process a couple of records sent through output.set() If one of the scripts fails it doesn’t seem to register that error in the overall automation. See image below, individual script failed, overall automation is giving me the green light. I noticed that the script wasn’t behaving correctly on some records but having the script not throw errors is potentially dangerous as problems stay hidden.


 

 

Hm, do you have a try catch in your code?  If you do have a try catch, try putting in a `throw` to get it to error out the way you want

 

If you don’t have a try catch set up, could you provide your script for troubleshooting purposes?  Scripts error out fine for me generally, even in repeating groups

 

 The repeating group code is too big to paste here but I have the code below which is also not thowing an error even though I am throwing an error. Sometimes I’m wrapping my code in a seperate function so code in nested try catch blocks are being caught. 

As you can see in the image its giving me the thumbs up but there is an issue that needs to be addressed and the script is thowing a console.error 


try {
// STEP 0: Input from config

const { userRecordId, recordId } = input.config();

if (!userRecordId) throw new Error("Missing required input: userRecordId");

// STEP 1: Define Tables

const userPreferencesTable = base.getTable('user_preferences');
const objectClassesTable = base.getTable('object_classes');

// STEP 2: Fetch user_preferences record for current user
const userPrefQuery = await userPreferencesTable.selectRecordsAsync({
fields: l'user', 'project'],
});

const userPrefRecord = userPrefQuery.records.find(
(record) => record.getCellValue('user')?.id === userRecordId
);

if (!userPrefRecord) throw new Error('No user_preferences record found for this user.');

const project = userPrefRecord.getCellValue('project');


if (!project) {
throw new Error('Missing project in user_preferences.');
};

// STEP 3: Prepare fields to create record

const newObjectClassFields = {
project: e{ id: projecto0].id }],
assembly_objects: c{ id: recordId }],
};

// STEP 4: Create the new record
const newObjectClassId = await objectClassesTable.createRecordAsync(newObjectClassFields);
console.log(`✅ Created new object_class with ID: ${newObjectClassId}`);

console.log("🎉 Script completed successfully.");
} catch (error) {
console.error(`❌ Error in script: ${error.message}`);
}

 


Could you try adding a ‘throw’ after the ‘console.error’?


You mean a final throw errow after the last catch block?


Yeap


Reply