how to create record by using variable?

Hi Everyone,

I am trying to achieve this.

Once I am getting success response from API I need to insert a record in the table. for that, I have want to dynamically assign value to a variable whose data type is the same as the record. But unable to create value dynamically. Can anyone help?

Hi,

When you are consuming an API in the API window try testing it and copy the response to body, this should create the structure for you, then you can create a variable in your action with that datatype

Regards.

Hi Anu,

As prasad said you need to first create the structure from your response after that you need to set that structure in your action then call your CreateOrUpdateEntity.In that way your record will be created in your DB

Salman Ansari wrote:

Hi Anu,

As prasad said you need to first create the structure from your response after that you need to set that structure in your action then call your CreateOrUpdateEntity.In that way your record will be created in your DB

Hi but my API response is giving me only success value, not the record.. I need to create it dynamically by utilizing partial values sent in response. i.e I need to create record dynamically and then save it.


Prasad Rao wrote:

Hi,

When you are consuming an API in the API window try testing it and copy the response to body, this should create the structure for you, then you can create a variable in your action with that datatype

Regards.

I don't want to consume API response, I want to create record with one of its value, so is it possible?


Hi,

Dynamic structures are not possible in outsystems. You can store the JSON in text variable or if you know the datatype or structure of the value that you are extracting then you can use JSON utilities to extract information from JSON.

Can you mock up some sample response and explain exactly what you want to do? you will get accurate response from members.

Regards.

So My API's response is


{
  "operationId": "string",
  "success": true,
  "errorMessages": [
    {
      "propertyName": "string",
      "message": "string"
    }
  ],
  "data": {
    "responseValue": true
  }
}

 I just need "operationId" from that and my table where I want to add/save data is  like below:


Here is logic:

I have created a variable of datatype "slide" and now I need to assign value in order to create a record and then I want to insert it in table.

Is it possible?



Solution

Hi,

Look like you already have response structure. Yes that is possible and it would look something like below, where slide is my variable name with datatype slide .

Regards.

Solution

Prasad Rao wrote:

Hi,

Look like you already have response structure. Yes that is possible and it would look something like below, where slide is my variable name with datatype slide .

Regards.


Thanks,let me try this.I will update 

Prasad Rao wrote:

Hi,

Look like you already have response structure. Yes that is possible and it would look something like below, where slide is my variable name with datatype slide .

Regards.


Thanks Prasad it worked for me.