Cell Details Export via Business Rule

SRAI
New Contributor III

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.

SRAI_0-1642418299511.png

The issue is: Cell_Details.csv file is getting generated in File Share folder but is empty (as shown below):

SRAI_1-1642418796432.png

 

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

 

1 ACCEPTED SOLUTION

ChristianW
Valued Contributor

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?

View solution in original post

10 REPLIES 10

ChristianW
Valued Contributor

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.

SRAI
New Contributor III

Hi Christian,

Sorry it has E#. I didn't put it here by mistake.

ChristianW
Valued Contributor

It shouldn't that might be the problem.

ChristianW
Valued Contributor

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?

SRAI
New Contributor III

Hi Christian,

It worked. my mistake. Thanks 🙂

SRAI
New 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
Valued Contributor

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

 

SRAI
New 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. 

SRAI_2-1642588662965.png

 

 

 

ChristianW
Valued Contributor

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.

SRAI
New Contributor III

Hi Christian,

There might be some process blocking my export and causing error. I will ask the admin to check this. I will also add a time stamp to see if the problem goes away.

Thanks for the suggestions.