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 9183b6dd3a
commit a9b846fdc2
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()