class UCL_DataProject
{
public static void main(Args _args)
{
#DMF
SharedServiceUnitFileID fileId;
DMFDefinitionGroupName definitionGroupName = "CustomerAgingDataStorage";
try
{
EntityName entityName = DMFEntity::findFirstByTableId(tableNum(CustomerAgingDataStorageEntity)).EntityName;
QueryBuildRange qbr;
QueryBuildDataSource qbds;
// Start:Optional if you want to filter data while exporting
Query query = new Query(DMFUtil::getDefaultQueryForEntityV3(entityName));
qbds = query.dataSourceTable(tableNum(CustAgingDataHeaderStorage));
qbr = qbds.addRange(fieldNum(CustAgingDataHeaderStorage, BatchName));
qbr.value(queryValue("30.09-2024-10-29T16:37:38"));
// End
DMFEntityExporter exporter = new DMFEntityExporter();
fileId = exporter.exportToFile(entityName,
definitionGroupName,'',"Excel","@ApplicationFoundation:DMFExportOperation",query.pack(),curext()
);
if (fileId != '')
{
str downloadUrl = DMFDataPopulation::getAzureBlobReadUrl(str2Guid(fileId));
System.Uri uri = new System.Uri(downloadUrl);
str fileExt;
if (uri != null)
{
fileExt = System.IO.Path::GetExtension(uri.LocalPath);
}
Filename filename = strFmt('MyFirstExport%1',fileExt);
System.IO.Stream stream = File::UseFileFromURL(downloadUrl);
File::SendFileToUser(stream, filename);
}
else
{
throw error("DMF execution failed and details were written to the execution log");
}
info("Export had been done successfully");
}
catch
{
error("error occurred while exporting");
}
}
}
In the below format customer looking for the excel file:
DMFEntityExporter exporter = new DMFEntityExporter();
fileId = exporter.exportToFile(entityName,
definitionGroupName,'',"Package","@ApplicationFoundation:DMFExportOperation",query.pack(),curext()
);