a!localVariables( local!priceId: http!request.queryParameters.pgenId, local!docId: http!request.queryParameters.docId, local!entities: a!forEach( items: local!pgenId, expression: a!queryEntity( entity: cons!DS_ENTITY1, query: a!query( logicalExpression: { a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "priceid", operator: "=", value: local!priceId ), } ) }, pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: true ).data, a!queryEntity( entity: cons!DS_Entity2, query: a!query( logicalExpression: { a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "docId", operator: "=", value: local!docId ), } ) }, pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: true ).data, ), /* * Construct an HTTP response that contains the information that we just stored * in "local!entities". */ a!httpResponse( /* * Set an HTTP header that tells the client that the body of the response * will be JSON-encoded. */ headers: { a!httpHeader( name: "Content-Type", value: "application/json" ) }, /* * JSON-encode the value of "local!entities" and place it in the response body. */ body: a!toJson(value: local!entities) ) )
Discussion posts and replies are publicly visible
You shouldn't.
We can try to help if you try to explain your question further.
I would like to apply a loop to retreive data in json format through querying 2 entities. In other words, when we select an id, they should retrieve a format data with 2 tables.
Basically, you should not query data in a loop. Can you explain why is it necessary to use a loop.
I recognize. In fact, we shouldn't apply a loop for querying datas in table. In this case, we have 2 entities and we want to loop by id to retreive 2 datas in json format because entity 1 reference entity 2. They have some similar and complementary fields.
Also I see your code, you have called two query entities in the foreach without the expression being a list.