Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve single record in cloud functions in sap build apps

erza
Explorer
0 Kudos
182

One of our requirements is to preload the page with whatever data is stored in the application backend upon opening of the app. The simplest way (I think) is to create a data variable that retrieves a single data record using current logged in user's information (for this particular case, I am thinking of using the email). Returned data will then be saved as a variable to pre-populate fields. The problem is, retrieving a single record from the entity requires me to pass the id, which is, by default, an automatically generated uuid upon data creation. Is there a way to retrieve a single record without passing the uuid, instead pass a different input that can uniquely identify the entry (user's email)? If not, how can I get the uuid that I need to retrieve the single entry?

2 REPLIES 2

agpekka
Product and Topic Expert
Product and Topic Expert
129

Hello,

You should retrieve a list of records, but filter it based on the user email, to retrieve the row you want.

BR, Pekka

0 Kudos
98

Hi Pekka,

Thanks! That is actually the workaround I did. However, I used a data variable to retrieve instead of using the get list function in vcf. I'm having issues with the get list function returning an "unexpected error" and then no other information. Would you know what's causing this and/or where can I go to troubleshoot this some more? Like some logs, stacktrace, etc?

Below are screenshots of a test page I created to demo. Page contains a button, upon click will run the cloud function 'test func' and will show an alert dialog box if success or error. Another screenshot for the implementation of 'test func'.

Opening dev console, this is the response when clicking the button

{
    "status": 200,
    "statusText": "OK",
    "headers": {
        "access-control-allow-origin": "*",
        "allow": "OPTIONS,GET,HEAD,POST,PUT,PATCH,DELETE",
        "access-control-allow-headers": "content-type, authorization",
        "access-control-allow-methods": "OPTIONS,GET,HEAD,POST,PUT,PATCH,DELETE",
        "access-control-allow-credentials": "true",
        "strict-transport-security": "max-age=63072000; includeSubDomains; preload",
        "content-security-policy": "default-src 'none'",
        "content-type": "application/json; charset=utf-8",
        "date": "Tue, 25 Mar 2025 05:40:06 GMT",
        "x-envoy-upstream-service-time": "9",
        "server": "istio-envoy",
        "connection": "close"
    },
    "responseText": "{\"id\":\"7267fe0a-6431-4c2a-85de-f120bab6a8e7\",\"functionId\":\"8424c4b6-96af-4601-84b3-0b2a594e4f8b\",\"inputs\":{},\"startedAt\":\"2025-03-25T05:40:06.849Z\",\"completedAt\":\"2025-03-25T05:40:06.850Z\",\"terminationRequested\":false,\"output\":{\"id\":\"unexpectedError\",\"kind\":\"error\",\"values\":{}}}"
}

error-msg.pngget-list-function.pngtest-page-trigger.png