Skip to main content
Dec 29, 2021 8:40 PM UTC

Trapping WF Import/Validate/Load Errors

Does anyone have any sample code they can share to see how to trap errors during an automated dataload process?  Currently, all I can see is that the dataload process executed and completed but it does not tell you if something happened in between.  I'm having no luck capturing if an error was encountered during the import or validate steps.

9 replies

Member
Jan 3, 2022 1:58 PM UTC

I believe you lliterally need to capture the status:

Dim MyTimeDimAppInfo As TimeDimAppInfoEx = New timeDimAppInfoEx
Dim statusMsg As String = batchInfo.GetCompleteBatchStatusMessage(si, MyTimeDimAppInfo, True, True)

The statusMsg will be the placeholder for the, well, status messages, that you can sort thru, display via error log or send by email. Something like:

If statusMsg.IndexOf("Validate Intersections")...

Contributor
Jan 3, 2022 5:22 PM UTC

Here's an example that executes a direct connect import and captures the status. If the status of wfUC_Import contains an error, the code logs the message, sends out an e-mail, and exits the rule. If no error is found, it logs a successful completion and moves on to the next step.

Execute Direct Connection Load Method with Error Tracing.png

Here's the actual code:

'Define the Workflow unit cluster
Dim wfUC As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, wfChannelName, ScenarioName, TimeName)

'Execute Data management load to process the workflow channels

'Excecute direct connection load method
Dim wfUC_Import As LoadTransformProcessInfo = BRApi.Import.Process.ExecuteParseAndTransform(si, wfUC ,"NA", Nothing, LoadMethod, directConnection, False)
logMsg = "Import: " & wfUC_Import.LogMessage & vbCrLf
If wfUC_Import.HasError 'Update the log message and Send e-mail on error
logMessage += ">>> " & wfUC_Import.LogMessage & vbCrLf
logMessage += "Import step has errors. Click the [Refresh Application] button in the top right corner to proceed."
Me.SendNewMemEmail(si, globals, api, args, timeName, wfChannelName, harvestFilePath, "Error", logMsg)
GoTo GetOut
Else
logMessage += ">>> Import step " & wfUC_Import.Status.ToString & ". Row count=" & wfUC_Import.RowCount & ". Duration=" & wfUC_Import.FullProcessDuration & " Milliseconds." & vbCrLf & vbCrLf

End If
'********* debug info *********
If debugSwitch = True Then brapi.ErrorLog.LogMessage(si,"Import: " & wfUC_Import.LogMessage)
'******************************

Jan 4, 2022 8:43 PM UTC

Thank you Koemets and Gidon_Albert  for sharing your ideas.  These helped a lot.  I was able to figure out how to handle if the autoload process encountered an error by using the statement below:

Dim state = brapi.Workflow.Status.GetWorkflowStatus(si, si.WorkflowClusterPk, True)

 If state.HasErrors = "True"
'Do Something
End If

 

 

Contributor
Jan 5, 2022 2:30 PM UTC

Hi Jun, 

Did you build this rule within Extensibility rule?

 

Jan 5, 2022 2:41 PM UTC

Mustafa_A  Yes.

Newcomer
Mar 16, 2022 9:36 PM UTC

Hello,

 

can you please share with me the code used to automate the workflow (import,validate,load) ? 

thank you

Contributor
Apr 26, 2022 10:18 PM UTC

Hi Kevin,

Happy to share the code, but there is a limit to the number of characters a message can contain. Happy to share via e-mail. I'm at mailto:gidon.albert@morganfranklin.com .