How to use a!exportDataStoreEntityToExcel() in web api

Hi!

Can someone explain how do I use a!exportDataStoreEntityToExcel() in web api? im still learning about webapi if someone could simplify it for me or give me some documentation, or both, I would really appreciate it.

Thank you

  Discussion posts and replies are publicly visible

Parents
  • You can create a POST method Web API and try out the below sample code which will return the excel document generated.

    a!exportDataStoreEntityToExcel(
      entity: cons!DATA_STORE_ENTITY,
      documentName: cons!DOCUMENT_NAME_TO_BE_GENERATED,
      sheetName: "EXCEL_SHEET_NAME",
      saveInFolder: cons!DOCUMENT_SAVE_FOLDER,
      selection: a!querySelection(
        columns: {
          a!queryColumn(
            field: "column1"
          ),
          a!queryColumn(
            field: "column2"
          )
        }
      ),
      filters: a!queryLogicalExpression(
        ignoreFiltersWithEmptyValues: true(),
        operator: "AND",
        filters: {
          a!queryFilter(
            field: "column1",
            operator: "=",
            value: "filterValue"
          )
        }
      ),
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(
            name: "Content-Disposition",
            value: concat(
              "attachment; filename=""",
              document(
                fv!newDocument,
                "name"
              ),
              ".",
              document(
                fv!newDocument,
                "extension"
              ),
              """"
            )
          )
        },
        body: fv!newDocument
      ),
      onError: a!httpResponse(
        statusCode: 500,
        headers: {},
        body: "500 Internal Server Error"
      )
    )

Reply
  • You can create a POST method Web API and try out the below sample code which will return the excel document generated.

    a!exportDataStoreEntityToExcel(
      entity: cons!DATA_STORE_ENTITY,
      documentName: cons!DOCUMENT_NAME_TO_BE_GENERATED,
      sheetName: "EXCEL_SHEET_NAME",
      saveInFolder: cons!DOCUMENT_SAVE_FOLDER,
      selection: a!querySelection(
        columns: {
          a!queryColumn(
            field: "column1"
          ),
          a!queryColumn(
            field: "column2"
          )
        }
      ),
      filters: a!queryLogicalExpression(
        ignoreFiltersWithEmptyValues: true(),
        operator: "AND",
        filters: {
          a!queryFilter(
            field: "column1",
            operator: "=",
            value: "filterValue"
          )
        }
      ),
      onSuccess: a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(
            name: "Content-Disposition",
            value: concat(
              "attachment; filename=""",
              document(
                fv!newDocument,
                "name"
              ),
              ".",
              document(
                fv!newDocument,
                "extension"
              ),
              """"
            )
          )
        },
        body: fv!newDocument
      ),
      onError: a!httpResponse(
        statusCode: 500,
        headers: {},
        body: "500 Internal Server Error"
      )
    )

Children
No Data