How to call exportDataStoreEntityToExcel on page load

Hi,

I want to export the data in excel on page load using ExportDataStoreEntityToExcel. how we can achieve this? I am successfully able to export the data on saveinto but here want to export on page load. Below is the code which i am trying. Code is not throwing any error but seems not calling this export service also.

local!exportDocId:
a!exportDataStoreEntityToExcel(
entity: cons!SCE_SITS_VW_INCIDENTS,

documentName: "test Report",
sheetName: "Test Report",
saveInFolder: cons!TEST_DOCUMENT_FOLDER,

onSuccess: a!save(
local!exportlink,
fv!newDocument
),
/*This displays an error if there is an issue executing the save*/
onError: a!save(
local!errorMessage,
"Error Exporting File to Excel"
)
),

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    To achieve exporting data to Excel on page load using the ExportDataStoreEntityToExcel function, you can use the following code:

    local!exportDocId,
    local!exportLink,
    local!errorMessage,
    {
    a!save(
    local!exportDocId,
    a!exportDataStoreEntityToExcel(
    entity: cons!SCE_SITS_VW_INCIDENTS,
    documentName: "test Report",
    sheetName: "Test Report",
    saveInFolder: cons!TEST_DOCUMENT_FOLDER,
    onSuccess: a!save(
    local!exportLink,
    fv!newDocument
    ),
    onError: a!save(
    local!errorMessage,
    "Error Exporting File to Excel"
    )
    )
    ),
    a!save(
    fv!exportDocumentId,
    local!exportDocId
    ),
    a!save(
    fv!exportLink,
    local!exportLink
    ),
    a!save(
    fv!errorMessage,
    local!errorMessage
    )
    }
    )```

    This code utilizes the `a!localVariables` function to declare and assign local variables for `exportDocId`, `exportLink`, and `errorMessage`. Within the `a!localVariables` function, we make use of the `a!save` function to store the values of the `exportDocId`, `exportLink`, and `errorMessage` variables.

    Please ensure that you have the appropriate configuration for the `cons!SCE_SITS_VW_INCIDENTS` entity, `cons!TEST_DOCUMENT_FOLDER`, and the necessary data to be exported to Excel.

    By implementing this code, the data export to Excel will be triggered automatically on page load. The exported Excel document will be saved in the specified folder (`cons!TEST_DOCUMENT_FOLDER`). If the export is successful, the `exportLink` will contain the link to download the exported Excel file. In case of any error during the export process, the `errorMessage` will be populated with the appropriate message.

    Feel free to modify the code as per your specific requirements, and let me know if you need any further assistance!

  • Throwing error. Please let me know what i am doing wrong here. Thanks



  • 0
    Certified Lead Developer
    in reply to palasha1583

    This is the indication that this will not work. Really!

Reply Children
No Data