Skip to main content
August 7, 2024
Solved

How do I give the field of a!querycolumn() when querying from datastore

  • August 7, 2024
  • 3 replies
  • 0 views

I'm querying from a datastore, I only need one column, how do I give the column name in field

    Best answer by bhargavip7872

    Hi [mention:2aea1bf0b6954f94815518e79da990c7:e9ed411860ed4f2ba0265705b8793d05]  please use below code

    a!queryEntity(
    entity: cons!test,
    query: a!query(
    selection: a!querySelection(
    columns: a!queryColumn(
    field: "columnsNameAsInCDT"
    )
    ),
    pagingInfo: a!pagingInfo(1,10)
    )
    ).data

    you can change paging as your requirement 

    3 replies

    bhargavip7872
    August 7, 2024

    Hi [mention:2aea1bf0b6954f94815518e79da990c7:e9ed411860ed4f2ba0265705b8793d05]  please use below code

    a!queryEntity(
    entity: cons!test,
    query: a!query(
    selection: a!querySelection(
    columns: a!queryColumn(
    field: "columnsNameAsInCDT"
    )
    ),
    pagingInfo: a!pagingInfo(1,10)
    )
    ).data

    you can change paging as your requirement 

    August 7, 2024

    Thanks

    August 7, 2024

    You have to give the CDT's field name in a!queryColumn. See the sample code for reference:

    a!queryEntity(
      entity: cons!DU_DOC_TYPE_DSE,
      query: a!query(
        selection: a!querySelection(
          columns: {
            a!queryColumn(
              field: "docTypeName"
            )
          }
        ),
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 50
        )
      ),
      fetchTotalCount: false
    )