How can I copy or move the list obtained from external database using the existing entity to a New Entity?

0
Here I have created a entity climatelog which is used by external database to display the data’s as list, and those data’s retruned as list is to be copied to entity climatelog_2, How can I acheive this step. Down I have attached my entity and microflow diagram.
asked
3 answers
1

Hi Krishna,

  1. First create empty list of climatelog_2 after execute quesy (as the you want data’s retruned as list is to be copied to entity climatelog_2)
  2. Then add loop activity and set iterator object as Climate_List(i.e ldata’s return as a list)
  3. Inside loop you can create object of climatelog_2 with all the attributes listed in the entity 
  4. Add that object to list that created before loop(i.e climatelog_2_List)
  5. And commit list of object outside the loop.

you can refer below microflow,

This way data’s retruned as list is to be copied to entity climatelog_2.

answered
0

Hi Krishna,

 

You can add a loop after your query that iterates over the list. Within the loop you can create an object of climatelog_2 for each climatelog in the list.

answered
0

Hi Krishna,

the “Result object” param of the java action only cares about the meta object type so that it can create the result list of that same object type. So you could just call the execute query statement configured with a newly created object “$climatelog_2”.

 

If you’re interested in having two lists of both object types (one list of climatelog and one of type climatelog_2), the you can perform two execute query actions, one with your created climatelog and one with a newly created climatelog_2 object as result object param.

 

This is assuming that your attribute names of climatelog and climatelog_2 are indeed the same. If they differ, you need to make sure in the SELECT statement that the column names are returned with the same attributes names as your climatelog_2. So for example if ‘TEMPERATURE’ is called MaxTemp in climatelog_2, then you need to write your select statement as  ‘SELECT ResultTableName.TEMPERATURE as MaxTemp’.

 

Alternatively, you can of course still apply the proposed solutions above and copy on list to another according to your needs (e.g. using community commons Clone java action (for same attribute names) or using default Mendix Create Object where you copy over the attributes according to your own needs.

 

answered