Fix: workflow assignment of customfield fails if field exists in v2.3.1 (#5302)

This commit is contained in:
shamoon 2024-01-07 14:27:57 -08:00 committed by GitHub
parent 9f6613fe05
commit c64667d396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 4 deletions

View file

@ -610,10 +610,18 @@ def run_workflow(
if action.assign_custom_fields is not None:
for field in action.assign_custom_fields.all():
CustomFieldInstance.objects.create(
field=field,
document=document,
) # adds to document
if (
CustomFieldInstance.objects.filter(
field=field,
document=document,
).count()
== 0
):
# can be triggered on existing docs, so only add the field if it doesnt already exist
CustomFieldInstance.objects.create(
field=field,
document=document,
)
document.save()