Call an Epicor Function asynchronously

Is it possible to return data from ScheduleAgent back to function that called it ?

thanks

No, but you can write data like a tag, or something and wait on it in your function.

I have done something similar when I needed to.

What are you trying to do? I may have some pointers.

1 Like

That is such a nifty idea… Great idea and solution.

My function is going to call an existing set of functions that creates and schedules a job for a single line, but now this new function will call the job creation stuff for multiple/many lines (so it can take some time, hence asynchronous).

In this case some may be successful and some may fail, I would like to return a list of status’s and if failures the reasons.

I thought about maybe writing the info to a UD table but even with that, I would need some kind of trigger to know when the whole process is finished, and then I could read the results from the table (and clear it for next run)

Another thought would be to just check for existence of the jobs when finished and skip the cause of failures part, but I still am not sure how to determine when it’s finished

Thanks !

Neat. I just woke up, but I’ll chew on that and get back to you.

Thank you for sharing this! It’s proven to be very handy!

1 Like

I decided that I will gather my results, and when my 2nd function (the one that loops thru the lines to create jobs) is near finished, at least for now, sending an email to the current user with the results for each line will suffice

1 Like

Yeah sorry I didn’t get back with you, been a bit busy. :wink:

1 Like

What about having your function write status to the system monitor?

If you are instead wanting to wait on this programmatically, you’ll have to do polling.

I made something similar recently, I have a structured logging table, and I added the same functionality as SysTag to it. I could have just extended SysTag to do what I wanted, but I chose to put my “tags” in the same table as logging for easy cleanup and organization.

Anyway, I wrote some functions and helper functions to write “tags” to my logging table, and that allowed me something to poll against. My tag functions would accept an extra Guid which allowed easy querying, or if you didn’t provide one, it would make it’s own.

Using the same idea, in your main function (run asynchronously), you could run other functions (sync or async) and write tags with your desired output data. (You would add this functionality to your other functions.)

You could poll for the existence of the tags by guid, probably have a timeout period, etc, and send a notice when done.

Personally, I would simplify it and only run the main function async, have good error checking (unless you have problems with hangs), and send a notice when done.

This is probably a better solution than mine, but I write mine to CSV files (a new one each month) in the EpicorData\Companies\Company\Logs directory. Depending on the process I set up a teams alert or email that lists the # of failures if any.


Hello, what am I missing?

You have to declare you references here.

Also, if you are like me, you’ll forget to grant access to the company too…

3 Likes



costom code function is available!

Widget Function with Code still doesn’t work. :thinking:

What does your Services tab show?


Does this need to select a service?

1 Like

Yes.

2 Likes