Skip to main content
September 29, 2023
Solved

I would like to loop for querying two tables with id

  • September 29, 2023
  • 6 replies
  • 0 views

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)
  )
)

    Best answer by aryan.7325

    We can try to help if you try to explain your question further.

    6 replies

    Inspiring
    September 29, 2023

    You shouldn't.

    Inspiring
    September 29, 2023

    We can try to help if you try to explain your question further.

    September 29, 2023

    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.