Casting list object with IMendixObject

6
Getting an error on casting object to IMendixObject, "cannot be cast to com.mendix.systemwideinterfaces.core.IMendixObject" Code as below. private List<IMendixObject> convertListToMendixObject(List <nta.proxies.InspectionTiming> inspectionTime) { List <IMendixObject> inspectionTimeListIMO = new ArrayList<IMendixObject>(); for (InspectionTiming inspectionTimeListElement : inspectionTime) inspectionTimeListIMO.add((IMendixObject)inspectionTimeListElement); return inspectionTimeListIMO; } `
asked
1 answers
12

I'm assuming the object you're trying to cast is a Mendix proxy object? In that case you should use the getMendixObject() method of that proxy object to obtain a IMendixObject:

inspectionTimeListIMO.add(inspectionTimeListElement.getMendixObject());
answered