Validation only updates once clicking on diagram again

My validation code ( in camunda custom properties panel) for input on the id field works but only once you hit the diagram a second time, unless i put in a bpmn validation error like a number for the id, in which case it updates immediately. any idea what I am doing wrong? Thank you!

    validateCreateFields (firstIdEntryOrUndefined, errors?) {
        let validationErrors = { id: '' }

        firstIdEntryOrUndefined.validate = (element, values) => {
            const currentName = values.id;

            // validate
            const inputError = utils.validateId(currentName, this.translate);

            // if bpmn validation errors
            if (inputError) {
                validationErrors.id = inputError;
                this.workflowMessageService.emit(true);
                return validationErrors;
            // else perform check if id exists already
            } else {
                this.workflowService.getDiagram(currentName).subscribe(
                    () => {
                        validationErrors.id = validationText.alreadyExists;

                        this.validateCreateFields(firstIdEntryOrUndefined, validationErrors);
                        return;
                    },
                    (err) => {
                        validationErrors.id = '';
                        this.validateCreateFields(firstIdEntryOrUndefined, validationErrors);
                        return;
                    }
                );

            }
            return inputError? { id: inputError }: errors;
        }
    }

You’re validating asynchronously, which may be an issue.

How do you assume validation works? How would it need to work for above code to work?

Hi @nikku - I would think that if .validate returned a promise? I’m fairly new to promises but that is what I kept thinking would help. Maybe I’ll try in a fiddle.