We have one dev org(without namespace) and one packaging org(with namespace) for developing lightning app. We are trying to access custom field in Lightning helper method as expence__c. It works fine in dev org. But in managed package response returned from the server controller prefixes namespace to given field as namespace__expence__c.
Code tries to access field expence__c which in turn gives field undefined error.
We can't hardcode namespace in code as it won't work in dev org.
We found two solution to this.
Add/Remove namespace to field depending on org in Lightning code. (not preferred)
Write DTO(data transfer object) class for all objects which we wish to use in Lightning. (need to create multiple DTO classes for those objects)
What is the best way to handle given problem.