cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Variable from formula data variable not appearing

louis_ribault
Explorer
0 Likes
1,627

Hi,

I am trying to extract information from a SAP destination.

The response from my API call looks like this:

(This is the response that shows when using the "Test" tab)

{ "value": [ { "id": "j9f7qe50-r5bb-45cj-7cd4-386c34658pa5", "projectId": "5c6fhe73-epa1-i9c6-9b0j-649fd9hec53t", "name": "AAAAA", "description": null }, { "id": "4ad51t1b-3cy4-4b40-a6cr-r4hbdb017cc1", "projectId": "5c6fhe73-epa1-i9c6-9b0j-649fd9hec53t", "name": "Test 1", "description": "test created with new app" }]}

I used the auto detect schema from response which gave me a set of variables as follows:

Now when trying to use this data in a text for example Appgyver tells me to use the following formula:
"data["CalmAPI-Scopes1"][0].value[0].name"
Which should seem logical to get out the first name of the Data I just extracted.

But when the application is launched no information shows up in the text section where the name should be.


I was wondering if maybe I am using the wrong formula to extract the "name" variable and if there is another way to do it.


After doing some research I realise that using the "Response Mapper" option could help with the extractionof this data, but I cannot seem to find any documentation explaining how to use this Response Mapper.Does that documentation exist and if it does would it be possible to get a link to it?

And with the Response Mapper is there anyway to get only the information like follows:


{ "id": "j9f7qe50-r5bb-45cj-7cd4-386c34658pa5", "projectId": "5c6fhe73-epa1-i9c6-9b0j-649fd9hec53t", "name": "AAAAA", "description": null }, { "id": "4ad51t1b-3cy4-4b40-a6cr-r4hbdb017cc1", "projectId": "5c6fhe73-epa1-i9c6-9b0j-649fd9hec53t", "name": "Test 1", "description": "test created with new app" }}


And getting rid of the "value:" I think this would help with the clarity of the data and its usage.


I don't this the issue comes from data not existing as when I run the test I get the Json response that was shown above.

Accepted Solutions (0)

Answers (2)

Answers (2)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

You can use a similar functionality in the REST calls with BTP destination. You need to set the mapper to something like this:

{ records: response.data.team_all_season.queryResults.row, driverCode: response.status }

where "team_all_season.queryResults.row" provides the path to the list. You can see the schema to the MLB API I used here: https://appac.github.io/mlb-data-api-docs/#team-data-list-teams-get

I would imagine in your case it would be something like this:

{ records: response.data.value[0], driverCode: response.status }
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Likes

In your API, you would put in the response key path "value", which tells AppGyver that that is where the collection is located.

Usually, you would store this data in a data variable, and from a function you would access it this way:

data.myDataVar

or often the data variable would be used in a Repeat property, and then you would bind this value:

repeated.current.myFieldName

If you are using destination with OData, then your destination must be set up to go to the base URL of the OData service. The above what I wrote is if you are using REST service.

louis_ribault
Explorer
0 Likes

I found the solution to my problem, the formula proposed by Appgyver to access the data is actually wrong.

Appgyver proposes : "data["CalmAPI-Scopes1"][0].value[0].name"

But the data only shows up when I use: "data["CalmAPI-Scopes1"].value[0].name"

Even though Appgyver gives me multiple errors in the formula screen when using the fomula that makes my data appear in my application

Screen shot of the errors Appgyver tells me I have with the working formula:

capture.png

Although this is annoying as I am using a formula that Appgyver doesn't recognize this makes it impossible to Repeat on this data and use the "Data item in repeat" which would be nice to have. And this also makes the function MAP on the data complicated to use as the tabs to find the data do not show my variables.

I guess I have to find a workaround using those.

Thanks for your help

dmalavasi
Explorer
0 Likes

Hi Daniel,

the mentioned "key path value" is only available in the direct API integration, but the BTP destination integration does not offer this "key path value". Do you know if there is a way to set this key path value also somehow in the BTP destination integration?
It seems that otherwise using the record collection doesn't properly work with Build apps, as it is always expecting a list of objects. I have tried all kinds of mappings and formula transformation, but it just always comes down to this: It's expecting a list already from the data entity.
As Louis already wrote, it does work with a formula, but Build apps cannot resolve it and therefor cannot create proper preview values, which makes it very hard to work with.
The direct REST API integration works like a charm, it would be great to have the same experience with the BTP destination integration.

Kind regards, David