On run schedule business process error

Hello community!

I have a business proces that when run manually works perfect but if use the schedule code, the code schedule the proces perfect but when ejecute return a error about the null object.

Can you help me to find the error?

The bussines proces to ejecute (think that error is about the userConnection):

var userConnection = (UserConnection)HttpContext.Current.Session[ "UserConnection" ];
 
var delete = new Delete(userConnection)
        .From("BGlobalSurveyLinks"); 
delete.Execute();
 
var insert = new Insert(userConnection).Into("BGlobalSurveyLinks")
	 .Set("Name", Column.Const(surveyLink))
	.Set("Description", Column.Const(surveyTitle)); 
insert.Execute();

The schedule code (that work perfect becouse the BP execute every 5 minutes):

var userConnection = (UserConnection)HttpContext.Current.Session["UserConnection"];
string schedulerJobGroupName = "BGlobal";//- any name
string jobProcessName = "BGlobalSincronize"; //- the name of the process
string schedulerJobName = "Schedule"; //- any name
AppScheduler.RemoveJob(schedulerJobName, schedulerJobGroupName);
var job = AppScheduler.CreateProcessJob(schedulerJobName, schedulerJobGroupName, jobProcessName, userConnection.Workspace.Name, userConnection.CurrentUser.Name);
var trigger = new SimpleTriggerImpl(schedulerJobName + "Trigger", schedulerJobGroupName, DateTime.UtcNow.AddMinutes(5));
AppScheduler.Instance.ScheduleJob(job, trigger);
return true;

 

Like 0

Like

1 comments

The business process doesn't work because you don't send "userConnection" in a correct format. Please upgrade your instance to 7.11 and use an out-of-the-box scheduler that was embedded into a business process designer.

https://www.bpmonline.com/release-7-11

 

Show all comments