Skip to main content
July 14, 2023
Question

How to call exportDataStoreEntityToExcel on page load

  • July 14, 2023
  • 8 replies
  • 0 views

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

8 replies

stefanhelzle0001
Brainy
July 14, 2023

You cannot call a smart service function outside of a user interaction.

July 14, 2023

Any thought how to achieve export to excel on page load? can we achieve it by creating process model and call the process model on page load?

mikes0011
Brainy
July 14, 2023

As far as I know, you'll need to require the user to click on something first.

miguelb9412
July 15, 2023

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!

July 17, 2023

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



stefanhelzle0001
Brainy
July 17, 2023

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