Export Data Store Entity To Excel

Certified Senior Developer

Hi,

Please suggest how can i fetch first 100 rows using export data store entity to excel.

In filters input we can use only a!queryFilter and a!queryLogicalExpression.

Thanks

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hi  

    Can you please try this logic it may help you

    a!localVariables(
      local!exportDocId,
      local!errorMessage,
      {
        if(
          isnull(local!exportDocId),
          /*This link field contains the link that starts the export*/
          a!linkField(
            labelPosition: "COLLAPSED",
            links: a!dynamicLink(
              label: "Export to Excel File",
              saveInto: {
                a!exportDataStoreEntityToExcel(
                  entity: cons!BHNC_DSE_RECRUITMENT,
                  documentName: "Excel Export " & now(),
                  saveInFolder: cons!BM_DOCUMENT_FOLDER,
                  filters: {
                    a!queryFilter(
                      field: "id",
                      operator: "in",
                      value: enumerate(100) + 1
                    )
                  },
                  onSuccess: a!save(local!exportDocId, fv!newDocument),
                  /*This displays an error if there is an issue executing the save*/
                  onError: a!save(
                    local!errorMessage,
                    "Error Exporting File to Excel"
                  )
                )
              }
            )
          ),
          {}
        ),
        if(
          /*This only displays the download link if a valid document was created*/
          not(isnull(local!exportDocId)),
          /*This changes the link to a download link for the newly created document */
          a!linkField(
            links: a!documentDownloadLink(
              label: "Download Excel File",
              document: local!exportDocId
            )
          ),
          a!textField(value: local!errorMessage, readOnly: true)
        )
      }
    )

  • 0
    Certified Senior Developer
    in reply to baji mekala

      Thanks for the reply!! but the sequence of the Id should be different and one more thing suppose if one row or record deleted from database it will not fetch the first 100 records because we are using Id filter. so we need something like paginInfo.

Reply Children
  • 0
    Certified Senior Developer
    in reply to yogeshc

    Actually my use case is :-
    Suppose if we have 300 records in the database , i have to show first 100 records in first excel sheet , second 100 records on second excel sheet and so on... so right now i am facing issue how to filter first 100 records , later we can update the same document with different export data store entity to excel.
    so question is how to filter first 100 records

  • 0
    Certified Senior Developer
    in reply to yogeshc

    you can get first 100 rows using query entity paginginfo, using those id's u can export whole data to excel. 

  • 0
    Certified Lead Developer
    in reply to yogeshc

    Hi Yoesh,

    I have one suggestion haven't tried that but it can work 

    STEP 1. Create a temp table in database similar to the DSE you want to export.

    STEP 2. Create a stored procedure with parameters and modify the query as per you needs and insert the data into temp table.

    STEP 3. Once the SP is executed use the Export DSE to excel for the temp table.

    STEP 4. Truncate the temp table so next time when put some different parameter to SP it gives you output for specific input only.

    STEP 5. Lets us all know if it worked for you :)