Local Entity Mapping Insert Record

Local Entity Mapping Insert Record

  

Hi,

I have two tables in my local entity:

Category & Products

Category : cat_id , cat_name

Products : prod_id , prod_name


This is the structure that created in my Data section when I consume the REST API.

Now As I want to create a mapping in both table, I manually added cat_id in Product table.

Thus the tables becomes like this:

Category : cat_id , cat_name

Products : prod_id , prod_name , cat_id


Here the problem is, when I fetch the Data from REST API & provide List's using ListAppend to respective table createAction.

Rest API Response Structure:

{
   "catData":[
      {
         "catId":1,
         "catName":"USA123",
         "productData":[
            {
               "prodID":1,
               "prodName":"DELL"
            }
         ]
      }
   ]
}


Here in Product List it ask me to give the cat_id, which I am not receiving.

How can  I overcome/resolve this.

Kindly


Hi Assif,

For each category(catData) you have a node with the products (productData). Therefore, the products that are within that node belong to that category. So you know the cat_id

Paulo Cação wrote:

Hi Assif,

For each category(catData) you have a node with the products (productData). Therefore, the products that are within that node belong to that category. So you know the cat_id

{
   "catData":[
      {
         "catId":1,
         "catName":"USA123",
         "productData":[
            {
               "prodID":1,
               "prodName":"DELL"
            }
         ]
      }
   ]
}

Marked in red

I have created a for-each loop in order to insert records respectively.

Is there any other way?


Solution

assif_tiger wrote:

I have created a for-each loop in order to insert records respectively.

Is there any other way?


I think you don't have problem in use foreach :)

Solution

Paulo Cação wrote:

assif_tiger wrote:

I have created a for-each loop in order to insert records respectively.

Is there any other way?


I think you don't have problem in use foreach :)


I thought there might be a optimized solution in Outsystems, thus I was searching apart for-each.

Thanks