You need to look at addDataValidationFeedback in the Core API.
https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/actionmanagement/CoreAction.html#addDatavalidationFeedback(com.mendix.systemwideinterfaces.core.IMendixIdentifier,java.util.Map)
Mina covered this as part of his talk on Creating and Debugging Java actions at this years Mendix World. Here's a link to the session, it’s worth a watch.
https://events.mendixworld.com/widget/mendix/world21/catalog/session/1621626724715001fi3l
Hope this helps.
Great video by Mina, I noticed the link doesn’t work so here is an alterative: https://www.mendix.com/videos/creating-and-debugging-java-action/
For reference when video link might become broken:
y
@java.lang.Override
public java.lang.Void executeAction() throws Exception
{
// BEGIN USER CODE
DataValidationInfo dataValidationInfo = new DataValidationInfo(ObjectToValidate.getId().toLong());
if(ObjectToValidate.hasMember(AttributeName)) {
dataValidationInfo.addErrorField(AttributeName, ValidationMessage);
this.addDataValidationFeedback(dataValidationInfo);
}
return null;
// END USER CODE
}
ou can tldw: