Return the attributes changed in a object

0
Hi community, I wrote a JA where I wil send a object as input and what to get the attributes which are changed on base of learning the mendix client API.  the below is the code, But I got error in getChangedMembers(); Did I missed anything, Kindly help me with this. Thanks in Advanced. public class CustomPusher extends CustomJavaAction { private IMendixObject __entity; private web.proxies.Profile entity;   public CustomPusher(IContext context, IMendixObject entity) { super(context); this.__entity = entity; }   @java.lang.Override public IMendixObject executeAction() throws Exception { this.entity = this.__entity == null ? null : web.proxies.Profile.initialize(getContext(), __entity);   // BEGIN USER CODE   List<String> changedMembers = entity.getChangedMembers(); List<Object> changedValues = new ArrayList<>(); for (String memberName : changedMembers) { IMendixObjectMember<?> member = entity.getMember(getContext(), memberName); Object changedValue = member.getValue(getContext()); changedValues.add(changedValue); } return changedValues;   // throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Java action was not implemented"); // END USER CODE }
asked
3 answers
1

Your Entity variable is initialized using the web.proxies.Profile class, which is a wrapper class around IMendixObject that is generated by Studio Pro. That class won't have the getChangedMembers() method.

 

You should define a generic Type parameter in your Java action, use that type parameter as your Entity in your parameter definition. Once you deploy for Eclipse, in Studio Pro, your code will have access to the unwrapped version of the IMendixObject.

 

Alternatively, you can get the IMendixObject from the proxy by calling getMendixObject() on the entity var

answered
0

Are you maybe missing an import at the top?

 

import com.mendix.systemwideinterfaces.core.IMendixObject;

 

answered
0

This looks like the Java Action is set to return a single object, but you are trying to return a list instead.

 

You will also have a mix of different types in the returned value, so I don't think Mendix will know how to handle those when returned. 

 

Are you just trying to record all of the changed values in an entity? If you are, have you looked at the AuditTrail module which does the same thing? This has platform support by Mendix.

https://docs.mendix.com/appstore/modules/audit-trail/

 

I hope this helps.

answered