Hi,
Is there an Action or any other save way to change the validation state of a certain field in the FormEngine?
The <PROJECT_NAME>-Usecase: There is validation logic that can only be computed on the Server and it will be triggered as soon as the Client sends a PATCH-Request on a resource. The Validation should not be separated from the PATCH-Request and thus cannot be called via an own Request in the course of a validateFull or validatePartly Action. The Server doesn’t implement anything of A12, but the resource will be edited on the Client in a A12 FormEngine, so we need a way to change the validation state of the Form manually.
Any Ideas how to solve this requirement?
Kind Regards,
Alex from <PROJECT_NAME>
Hi @alexander-pure-wind,
After receiving the validation information from server, you can dispatch the setMessageState
api.dispatch(FormEngineActions.command({
engineEvent: Commands.setMessageState({
messages: {} // messages receive from server
}),
activityId: action.payload.activityId
}));
to replace all error messages in the form. There is another action which is Commands.setMessageStateEntry to replace the message that you want to change.
Hope it helps 
Sorry for responding late. Yes, it helped! Thank you!
I want to add, that I spent a while searching for an error, because i misspelled one of the needed strings inside message and didn’t get a hint what went wrong.
For everyone else, who is wondering, how it should be formatted, a message object looks like this:
api.dispatch(
FormEngineActions.command({
engineEvent: Commands.setMessageStateEntry({
messageStateEntry: {
validationMessages: [
{
element: [
{ elementName: "yourContainer", index: 1 },
{ elementName: "yourField", index: 1 }
],
errorCode: "anyErrorCode",
errorKey: "anyUniqueErrorKey",
errorText: "Any Error Text that get's displayed.",
referencedFields: [
[
{ elementName: "yourContainer", index: 1 },
{ elementName: "yourField", index: 1 }
]
],
severity: "ERROR"
}
],
path: "/yourContainer[1]/yourField[1]"
}
}),
activityId: action.payload.activityId
})
);
…It might look different if your Field is nested deeper.
Kind regards,
Alex