Hi Martin, As suggested I am creating a new thread.
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");
}
}
}
1. I like to filter the data before exporting to excel based on the batch name, But the in query for testing I hardcore the "Batch name" and it is not working. And it's exported all data.
2.The EXCEL file is downloaded to the local machine in the Download folder perfectly.***
3, But the customer is looking for the file as a data project after downloading in the local machine in download folder as below:
In the below format customer looking for the excel file:
As suggested by you, I have checked the configuration for the Entity. The source data format was there earlier Excel. So, I have changed to Package and also change in the below code:
Code
DMFEntityExporter exporter = new DMFEntityExporter();
fileId = exporter.exportToFile(entityName,
definitionGroupName,'',"Package","@ApplicationFoundation:DMFExportOperation",query.pack(),curext()
);
and executed the code. but it return's TXT file instead of data project as below:
In my code, there are two problems as of now:
1. Query is NOT filtered based on the Batch name as mentioned above.
2. After exporting, data package is NOT generated as expected in download folder.
Please let me know what modifications are required.
Thanks!