Hi friends,
Does anyone know of a way to update the Task Status from a scheduled Function?
Imagine MRP ala “Next part to process”
I have a long running function that I sure would love to just update the status instead of writing logs every where. Thanks in advance and hope you are all doing FABULOUS.
klincecum
(Kevin Lincecum)
June 16, 2023, 11:37pm
2
Can you explain that a bit more Chris?
Hi Kevin, when I run an Epicor Function as task (on a schedule), I would like to populate the Activity status (I wrongfully called it TaskStatus which is different) with my task’s status.
1 Like
klincecum
(Kevin Lincecum)
June 17, 2023, 3:08am
4
Playing with it a bit, we can do it.
I gotta go for now, but I’ll hit ya back in the morning.
klincecum
(Kevin Lincecum)
June 17, 2023, 4:45pm
5
I got it working. Don’t have time to clean up my mess so I’ll post up later.
Y’all have a good weekend.
1 Like
🫨 Dang! Much thanks (and props) in advance
1 Like
tkoch
(Theodore Koch)
June 18, 2023, 1:42am
7
This may help @Chris_Conn
This should get the job done, could convert this to its own function and call it whenever is needed from another function. Should be useful as well to write out logging in cloud when debugging functions (or bpms) with no event viewer access
Action<string> writeToTaskLog = (message) => {
foreach (var activeTask in Db.SysTask.Where(t => t.Company == Session.CompanyID && t.TaskDescription.ToLower() == "run epicor function" && t.TaskStatus.ToLower() == "active"))
{
var taskLog = Db.SysTaskL…
3 Likes
klincecum
(Kevin Lincecum)
June 18, 2023, 4:58pm
8
Chris_Conn:
thanks
No problem Mr. Corn
tkoch:
This may help
It did, not quite the same, but I integrated your example as well.
https://www.epiusers.help/t/systaskmonitor-library-update-activity-message-write-to-task-log/104145
1 Like
klincecum
(Kevin Lincecum)
June 18, 2023, 5:21pm
9
And if y’all want to laugh at me…
In the test function, I made a typo at first.
while (keepLooping)
{
System.Threading.Thread.Sleep(1000);
TimeSpan timeElapsed = DateTime.Now - startTime;
if( timeElapsed.TotalSeconds >= numSeconds )
{
keepLooping = false;
}
if(bestGuessSysTaskNum > 0)
{
string testMessage = $"Elapsed Seconds: {timeElapsed.TotalSeconds.ToString()}";
//Activity Message
ThisLib.UpdateSysTaskMonitorActivityMessage(bestGuessSysTaskNum, testMessage);
//Task Log
ThisLib.WriteToTaskLog(bestGuessSysTaskNum, testMessage, (int)Epicor.ServiceModel.Utilities.MsgType.Info);
}
}
Instead of if( timeElapsed.
TotalSeconds >= numSeconds )
I had if( timeElapsed.
Seconds >= numSeconds )
The number of seconds I passed was 120.
Guess what happened…
2 Likes
klincecum
(Kevin Lincecum)
June 19, 2023, 1:10am
10
Lol, he made my screwup the solution, nice!