Forum Discussion

ssmith-nova's avatar
ssmith-nova
New Contributor III
9 days ago
Solved

BR works when run manually, but not through Task Schedule

I have the code below in an Extender BR.  It runs fine if I run it manually in the BR or manually through a DM job.  But when it runs in the Task Scheduler it fails, and I get the "Object reference not set to an instance of an object." error.  Any thoughts? 

	Dim wfUnitClusterPk As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, wfScenarioName, wfTimeName) 
	Dim ImportInfo As New LoadTransformProcessInfo 
	Try
		ImportInfo  = BRApi.Import.Process.ExecuteParseAndTransform(si, wfUnitClusterPk, "", Nothing, TransformLoadMethodTypes.Replace, SourceDataOriginTypes.FromDirectConnection, False)
	Catch ex As Exception
		log.AppendLine("Import Done - Status: " & ImportInfo.Status & " - RowCount: " & FormatNumber(ImportInfo.RowCount, 0,,,-1)) 
		log.AppendLine(ImportInfo.ErrorMessage)
		log.AppendLine("------------------------------")
		log.AppendLine(ex.GetBaseException.Message.ToString.Trim)
	End Try		

 

  • I'm not going to bother.  I moved it to a different dev application and It is working as expected.  Unless someone can think of a reason task scheduler wouldn't run BR correctly in an application I think my problem is resolved. I appreciate everyone's help.

    Scott

9 Replies

  • ssmith-nova's avatar
    ssmith-nova
    New Contributor III

    No, the BR is much longer, however the Execute Parse and Transform is the line that fails.

    • SimonHesford's avatar
      SimonHesford
      Contributor II

      But as rhankey pointed out you are referencing variables set elsewhere in your code so it be useful to see how you are setting these otherwise without that context it's difficult to help you out

  • rhankey's avatar
    rhankey
    Contributor II

    Have you verified what wfProfileName, wfScenarioName and wfTimeName are set to?  Have you checked that wfUnitClusterPk is set to something other than Nothing?

  • ssmith-nova's avatar
    ssmith-nova
    New Contributor III

    Yes I have validated all of that. 

    Here is the full code up to there:

    				Dim jobLog As New Text.StringBuilder
    				Dim returnValue As New List(Of Object)
    				Dim jobStatus As Boolean = True
    				Dim wfUnitClusterPk As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfileName, wfScenarioName, wfTimeName) 
    				Dim ProfileKey   As Guid    = wfUnitClusterPk.ProfileKey
    				Dim ScenarioKey  As Integer = wfUnitClusterPk.ScenarioKey
    				Dim TimeKey      As Integer = wfUnitClusterPk.TimeKey					
    				Dim wfProfileInfo As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, wfProfileName)
    				log.AppendLine($"*********************> {wfProfileInfo.Type}")
    				jobLog.AppendLine($"{Environment.NewLine}============ Workflow Start ============")
    				log.AppendLine($"{Environment.NewLine}============ Workflow Start ============")
    				jobLog.AppendLine($"       {DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")} UTC       {Environment.NewLine}")
    				log.AppendLine($"       {DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")} UTC       {Environment.NewLine}")
    				log.AppendLine($"  Workflow:                {wfProfileName}")
    				log.AppendLine($"  Scenario:                {wfScenarioName}")
    				log.AppendLine($"  Time:                    {wfTimeName}") 
    				log.AppendLine($"  WfPk:                    {wfUnitClusterPk}")
    				log.AppendLine($"  ProfileKey               {ProfileKey}")
    				log.AppendLine($"  ScenarioKey              {ScenarioKey}")
    				log.AppendLine($"  TimeKey                  {TimeKey}")
    				log.AppendLine($"  ----------------------------------------") 
    				log.AppendLine($"  Load & Transform:        True")
    				log.AppendLine($"  Validate Transformation: {valTransform}")
    				log.AppendLine($"  Validate Intersections:  {valIntersect}")
    				log.AppendLine($"  Load Cube:               {loadCube}")
    				log.AppendLine($"  Process Cube:            {processCube}")
    				log.AppendLine($"  Run Confirmation:        {confirm}")
    				log.AppendLine($"  Run Auto Certify:        {autoCertify}")
    				log.AppendLine("=======================================" & Environment.NewLine)	
    
    			
    				'---------------------------------
    				'   Parse and Transform:
    				'---------------------------------
    				Dim ImportInfo As New LoadTransformProcessInfo 
    				Try
    					log.AppendLine($"Here 1 {wfUnitClusterPk}")
    					ImportInfo  = BRApi.Import.Process.ExecuteParseAndTransform(si, wfUnitClusterPk, "", Nothing, TransformLoadMethodTypes.Replace, SourceDataOriginTypes.FromDirectConnection, False)
    					log.AppendLine("Here 2")
    				Catch ex As Exception
    					log.AppendLine("Import Done - Status: " & ImportInfo.Status & " - RowCount: " & FormatNumber(ImportInfo.RowCount, 0,,,-1)) 
    					log.AppendLine(ImportInfo.ErrorMessage)
    					log.AppendLine("------------------------------")
    					log.AppendLine(ex.GetBaseException.Message.ToString.Trim)
    				End Try	

     

    • rhankey's avatar
      rhankey
      Contributor II

      This code still does not show where wfProfile, wfScenario or wfTime are being set.  Have you added any diagnostics to see what those three variables are set to?  Have you checked to see if wfUnitClusterPk is set to something other the Nothing?

  • ssmith-nova's avatar
    ssmith-nova
    New Contributor III

    All of the log.Appendline statements show all of what you are asking about.  The first thing I checked before coming here is that all of the variables are populating correctly (Troubleshooting 101).  I am testing in a new app to see if it is an issue with the Task Scheduler in this app.  I copied code that is working fine in Prod back to Dev to see if it would work and it does not work in Dev.  I was hoping that someone had seen this behavior with Task Scheduler before. 

  • ssmith-nova's avatar
    ssmith-nova
    New Contributor III

    I'm not going to bother.  I moved it to a different dev application and It is working as expected.  Unless someone can think of a reason task scheduler wouldn't run BR correctly in an application I think my problem is resolved. I appreciate everyone's help.

    Scott