Create a task and call to a Business Process [SOLVED]
Hi all,
I wonder if is possible to create a task object and this task calls to a Business Process (or business operation)
My attempt was:
/// Task Special purge Class MyTasks.SpecialPurge Extends %SYS.Task.Definition { Parameter PROPERTYVALIDATION = 1; Parameter BPSPECIALPURGE= "Special Purge"; Parameter TaskName = "Special purge in SQL"; Property MinutesDelay As %Integer [ InitialExpression = 15, Required ]; Method OnTask() As %Status { // Create the date to purge set datePurge= $SYSTEM.SQL.DATEADD("minute",-1*..MinutesDelay, $HOROLOG) $$$ThrowOnError(##class(Ens.Director).CreateBusinessService(..#BPSPECIALPURGE, .tService)) If ($IsObject(tService)) { Set tSC = tService.ProcessInput(datePurge,.output) } } }
But it doesn't work.
Other attempt was extend the class to
set tSC = ..SendRequestSync(..#BPSPECIALPURGE, datePurge, .pOutput)
But this idea also doesn't work
Any idea how to do?
Best regards
I wonder why this is not working as i have called the service many times through custom tasks that i create.
You could, may be, put the code inside a Try/Catch to see what's the real problem.
Sample code from one of my tasks...
#Dim
Does not affect compilation at all.
Thanks for the solution.
The problem was that I should to call to a BS, not a BP instead. So I've created a dummy BS to call the BP to do the process.
Thanks again for the key
I see.. you need to may be declare the service class ...
#Dim tService As Service.class
Check out Demo.ZenService.Zen.WeatherReportForm class in ENSDEMO namespace. GetWeatherReport method there creates a BS and sends a message to a BP outside of Ensemble context. You need to send an object and not a datatype, so in your example:
Should be instead:
If you want to send a message to a BP or BO you can do that too, just create an Ensemble message and use SendSync or SendAsync to send it from BS:
That said, Ensemble hosts can run on schedule so you can use built-in Ensemble scheduler and not a system task manager.