Forum Discussion
SRAI
4 years agoNew Contributor III
Cell Details Export via Business Rule
Hello Experts,
I am trying to export Cell Details to a CSV using a business rule function as shown below:
If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("Export_CellDetails_CSV") Then
Dim wfUnitInfo As WorkflowUnitInfo = api.Workflow.GetWorkflowUnitInfo()
Dim SRCTimeName As String = wfUnitInfo.TimeName
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
Dim timeStamp As DateTime = DateTime.Now '.UtcNow
Dim AESTNow = System.TimeZoneInfo.ConvertTime(timeStamp, TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time"))
Dim timeString As String = AESTNow.ToString("yyyy_MM_dd_HHmm")
Dim xfolderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.fileShareRootFolder, si.AppToken.AppName)
Dim csvFilePath As String = xfolderPath & "\" & "Cell_Details.csv"
If File.Exists(csvFilePath) Then
File.Delete(csvFilePath)
End If
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "E#T_Entities", "E#EB1000", "S#ACTUAL", "T#2022M3")
End If
I am using a "custom calc" DM step to trigger the Business Rule function. Cell details are as shown in the form.
The issue is: Cell_Details.csv file is getting generated in File Share folder but is empty (as shown below):
I have provided all the intersections (copied from Cell POV Information) in the DM step but not sure why the contents are not getting exported.
Has anybody faced this issue before? May be I am doing something silly. Thanks.
Regards,
Sid
The E# (and the S#) is only needed, if it says filter in the parameter name, I like to correct my previous statement. In the help it says:
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, serverFilePath, entityDimensionName, entityMemberFilter, scenarioName, timeMemberFilter)
This means, your code should be like this:
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "
E#T_Entities", "E#EB1000", "S#ACTUAL", "T#2022M3")=
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "T_Entities", "E#EB1000", "ACTUAL", "T#2022M3")
Is it working?
10 Replies
- ChristianW
OneStream Employee
The entity dim name needs no 'E#' prefix.
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "T_Entities", "E#EB1000", "S#ACTUAL", "T#2022M3")
Might already work.
- SRAINew Contributor III
Hi Christian,
Sorry it has E#. I didn't put it here by mistake.
- ChristianW
OneStream Employee
The E# (and the S#) is only needed, if it says filter in the parameter name, I like to correct my previous statement. In the help it says:
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, serverFilePath, entityDimensionName, entityMemberFilter, scenarioName, timeMemberFilter)
This means, your code should be like this:
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "
E#T_Entities", "E#EB1000", "S#ACTUAL", "T#2022M3")=
Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "T_Entities", "E#EB1000", "ACTUAL", "T#2022M3")
Is it working?
- SRAINew Contributor III
Hi Christian,
The export works but gives an error: "The process cannot access the file '\\abcxyz.file.core.windows.net\onestreamsharedev1\FileShare\Applications\OneStreamDevelopment\DataManagement\Export\SiddarthRai\Cell_Details.csv' because it is being used by another process."
Do we need to close the file or kill some process to avoid this kind of error?
Thanks,
Sid
- ChristianW
OneStream Employee
I only get this error message, if the old document is still open in excel. Close excel and it will work.
This is the code I used for testing.
Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si) Dim xfolderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si,True, configsettings.fileShareRootFolder,si.AppToken.AppName) Dim csvFilePath As String = xfolderPath & "\" & "Cell_Details.csv" ' If File.Exists(csvFilePath) Then ' File.Delete(csvFilePath) ' End If Dim sValue As String = BRApi.Finance.Data.ExportCellDetailToCsv(si, csvFilePath, "HoustonEntities", "E#[South Houston]", "Actual", "T#2022M3")- SRAINew Contributor III
Hi Christian,
Cell_Details.csv was closed when I was getting the error. Based on your reply I closed all other excel instances and restarted my machine to make sure there is no hung instance but still same error. As you can see below there are only 2 programs opened.
- ChristianW
OneStream Employee
It is a network drive, is it possible, that other processes are blocking the file? Like a virus checker or a backup tool?
I don't think it is necessary a Onestream server problem, because I can't replicate the problems, but I work locally.
Some things you might like to test:
- Can you delete the file manually using the file manager? Is it then working?
- Can you remove the delete section from your script (i don't think it is needed).
- If you add a timestamp to the file name, you will always create a new file. Is it still creating this problem?
I hope some of this helps.
Related Content
- 7 months ago
- 4 months ago