isNew() Java Equivalent

2
In the modeller i have been using the isNew() function in microflows. However i can't seem to find the same functionality in the java. I want to use the isNew() functionality in a Java action instead of a microflow. Does anyone know how this is done? Thanks
asked
2 answers
2

In the apidocs I see that an IMendixObject has a method "getState" and the result is something of type "ObjectState" which is an enumeration with values CREATE, NEW, NORMAL. So I think

obj.getState() == ObjectState.NEW

will do the trick.

answered
0

My best guess would be implementing your own "isNew" in Java.

But I hope there is a prettier easier way :)

public boolean isNew(IMendixObject object) throws CoreException {
    Date createdDate = object.getCreatedDate(getContext());
    Date changedDate = object.getChangedDate(getContext());
    return createdDate != null && changedDate != null && createdDate.equals(changedDate);
}
answered