diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.js index 8de30e9c4..345ecfae4 100644 --- a/src/routes/api/attributes.js +++ b/src/routes/api/attributes.js @@ -28,8 +28,10 @@ function updateNoteAttribute(req) { || body.name !== attribute.name || (body.type === 'relation' && body.value !== attribute.value)) { + let newAttribute; + if (body.type !== 'relation' || !!body.value.trim()) { - const newAttribute = attribute.createClone(body.type, body.name, body.value); + newAttribute = attribute.createClone(body.type, body.name, body.value); newAttribute.save(); } @@ -37,7 +39,7 @@ function updateNoteAttribute(req) { attribute.save(); return { - attributeId: attribute.attributeId + attributeId: newAttribute ? newAttribute.attributeId : null }; } }