Scheduled Process - Run When Logged Out

I’m using the User Process Scheduler to schedule and run a BPM that iterates through past due invoices and routes them via APR. The code, itself works, but I’m finding I need to be logged in for it to actually process the invoices through APR. Is there a way it can run without being logged in?

The second issue is I have a condition in APR that will email if good, print if bad.
The printer never manifests anything. I have tried both client printer and server printer, but neither seem to do the trick. (The printer is installed on my client and it’s also installed on the server)

I can do without the printer, but I would really like to get this running without a user having to be logged in.
As a last resort, I’ll create a service account with a large session timeout, leave it logged in on the server, and have that account run it, but I’d rather not.

Is the 2nd issue (the lack of printing on a “bad” condition, all the time, or just when not logged in?

If the later, does the job print the next time you login in?

Appears to be all the time since the last time I ran it, I logged in and watched it run.
Nothing popped out of the printer, but there were no errors on those lines, either.

Does it even show up in the Sys Monitor? Try changing it to a print preview, and set the Archive for 1 week.

I’ll give that a shot this weekend when the process runs.

Do you have any evidence the process even runs? Maybe have it write the date and time to a UD field. Or send out a debugging email (one that has all static values for To, Subject and Body), place this high up in the flow - before any conditions.

I do. I have seen the records in the SysMon, though on the print ones I don’t recall if I’m able to print-preview it.
I can see where APR routes it to the emails (which succeed) and where it routes to the printer (Where nothing happens).
I also already have it writing the results to a CSV.

1 Like

This will also print the report to the specific printer as well - using this functionality you would be unable to just email the report without printing it. For an email of a report without printing, Epicor’s Advanced Print Routing/Breaking and Routing functionality would be an option. Please contact your CAM for details on that module. - This functionality is only available with SSRS reports.

This is the footnote from an Epicor KB Article. Which looks like you are limited without owning the Advanced Print Routing/Breaking and Routing functionality.

So Schedule the manager user to Print the Report and then it will Email =) lol

I’m actually using the Advance Print Routing module.

@hmwillett I schedule a print task for a report to run using the system agent. Is there any way you could do that?

I do not have to be logged in and the task still runs.

It would be nice to know how you are generating the invoice form through code and sending it out. I always wish I could do that.

@utaylor, that’s what the code is doing; it submits the print request to the task agent.

Very cool, I guess I am not familiar with the user process scheduler. There must be a difference in the way that runs and the way a scheduled report runs using the system agent. Sorry I can’t help.

I will have to check out the user process scheduler though, it sounds useful.

I love it.
It gives you the ability to schedule a BPM to run.
For instance, Epicor has a quote expiration process, but it doesn’t actually close the quote.
We use the UPS to run monthly, find all expired quotes, and close them.
Without it, the BPM would need some kind of trigger to run.

**Plus, it’s only, like, $800. Can’t go wrong there!

2 Likes

@hmwillett - What is the process you use to close expired quotes and how do you have it set up to run Epimagically? We are running into an issue where we have a ton of old quotes and are starting to use a CRM system and it is causing headaches with all the old quotes we have.

@EpsilonMaximus68Olds we use the User Process Scheduler which allows you to schedule a BPM to run.
When it runs, it runs this:

//==========================================================================================
//Author:  Aaron Willett
//
//Purpose: Close and Lose quotes that have expired. Writes an output file to
//         \\<server>\EpicorData\Companyies\ISI\Log\CloseQuote
//
//==========================================================================================
//REVISIONS
//==========================================================================================
//Initial: 02/14/2018 ADW
//
//==========================================================================================
string outStr = "RunDate: " + DateTime.Today.ToString() + Environment.NewLine;
string fileName = "CloseExpiredQuotes_" + DateTime.Today.ToString("MM-dd-yyyy") + ".txt";
string outPath = @"\\<server>\EpicorData\Companies\ISI\Log\CloseQuote\";

var result = (
	from qh in Db.QuoteHed.With(LockHint.UpdLock) 
	where qh.Company==Session.CompanyID && qh.ExpirationDate<=DateTime.Today && qh.QuoteClosed==false && qh.ReasonType!="W"
	select new {qh}).ToArray();
	
foreach(var quote in result)
{
	outStr += quote.qh.QuoteNum.ToString() + ", " + Convert.ToDateTime(quote.qh.ExpirationDate).ToString("MM-dd-yyyy") + Environment.NewLine;
  
	try
	{
    using(var taskBO = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.TaskSvcContract>(Db))
    {
      TaskTableset tTS = new TaskTableset(); 
      
      tTS = taskBO.GetByID("QuoteHed", quote.qh.QuoteNum.ToString(), "","",10);
      
      tTS.Task[0].Complete = true;
      tTS.Task[0].Conclusion = "LOSE";
      tTS.Task[0].ReasonCode = "EXP";
      tTS.Task[0].RowMod = "U";
      
      taskBO.Update(ref tTS);
    }
  
  	quote.qh.Expired = true;
  	quote.qh.ReasonType = "L";
  	quote.qh.ReasonCode = "EXP";
  	quote.qh.QuoteClosed = true;
  	quote.qh.ClosedDate = DateTime.Today;
	}
  catch(Exception e){outStr += e.ToString().Substring(0, 200) + Environment.NewLine;;}
}

using(StreamWriter sw = new StreamWriter(System.IO.Path.Combine(outPath, fileName)))
	sw.WriteLine(outStr);

Sometimes it will throw errors on various things (most often an inactive sales rep or not being authorized for said rep) in which case it will output the error to a file and someone will manually close it.

2 Likes

Finally getting around to trying this out. I’m definitely not good with C# coding. Can you tell me how to set an actual date in the qh.ExpirationDate<= spot? We have expired quotes open since 1999 and I don’t want to crush anything while trying to close these out.

Also, I’m getting the following errors when checking syntax:

DateTime expDate = new DateTime(2017, 1, 18); // Jan 1, 2017

var result = (
	from qh in Db.QuoteHed.With(LockHint.UpdLock) 
	where qh.Company==Session.CompanyID && qh.ExpirationDate<= expDate  && qh.QuoteClosed==false && qh.ReasonType!="W"
	select new {qh}).ToArray();

Thanks @ckrusen! That got me the date portion, but still having issues with the syntax errors.

You need to add a few using statements in the “Usings and References” section.

Without looking–you will need:
using System.IO;
using Erp.Tablesets;

On the assemblies, add:
Ice.Core.TaskBase (Or Task Something, I don’t remember)

The 2 using statements got rid of 2 of the errors, but still have the ones related to tasks, even after adding the Ice.Core.TaskBase. Any help is greatly appreciated.