fix(plugin-workflow): fix non-existed field in collection trigger cause error (#5318)

This commit is contained in:
Junyi 2024-09-25 19:51:49 +08:00 committed by GitHub
parent d335ffee7f
commit 2f57076d00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,9 +59,10 @@ async function handler(this: CollectionTrigger, workflow: WorkflowModel, data: M
changed &&
changed.length &&
changed
.filter(
(name) => !['linkTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(collection.getField(name).options.type),
)
.filter((name) => {
const field = collection.getField(name);
return field && !['linkTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.options.type);
})
.every((name) => !data.changedWithAssociations(getFieldRawName(collection, name)))
) {
return;