Invoking Process MRP from REST

Is it possible to invoke the Process MRP task via REST? Under what business object would I find the documentation the Process MRP task in the REST help?

Thanks,
Darrell

I imagine you could. I dont know what BO it would be, but I see a few for MRP. Perhaps a trace while running your MRP manually would give you that info.

1 Like

‘Task Agent’ is made up of two parts.
The Windows Service names Task Agent is what most folks think of as task agent but that is actually just an automated client. It wakes up every x ms and asks the ERP server if it has any work (logically it’s sitting there click on refresh in the Search list all day, every day).
When it finds it has work, it calls the RunTask service to do the work and passes just a small amount of information. The RunTask turns around and calls the appropriate service and internal libraries after that.

NOTE - A Task needs data staged before it is invoked (e.g. SysTaskParams). So there is no simple RunMRP(myParameters) call. (We ran into size limits on the volume of data that may get passed to a report or process ~17 years ago when this was being created so the two step staging of data process was done).

So depending on what exactly you mean by run mrp, yes but it’s not as simple as I want (yet).

1 Like

This is a “HACK” but a very useful hack. I use it in my Alexa Demo at Insights.The REST interface I use it almost exclusively for BAQs and this is one of those opportunities to do it without much complexity.

Write a Simple UBAQ (Updatable BAQ) that takes in a few parameters (those parameters that you want to make dynamic for running MRP)
Then use the Base Update processing of the UBAQ to invoke the process using the standard Epicor Business Objects.
I use a BAQ that does this for a Job Traveler Print… but the concept is the same.
It helps to think of UBAQs not merely as queries , but rather as Invokable little functions. @Bart_Elia may bark at this solution but IMO is simpler than dealing with all the Task BO’s from the REST side (for the time being).

Simple BAQ returns the current company record (just to return something)
image

As “display” I use Calculated fields (Updatable ones) to allow me to pass in the dynamic parameters to my report (or MRP)

http://jcg.pictures/gdggUhhPShbXA.png

Then use Advanced BPM Update Only and Run your custom C# to Invoke your report or MRP in the Base Process pulling in the values from those Calc_fields

Custom code

foreach(var s in ttResults.Where(r=>r.Updated()))
{
       s.Calculated_Sub="true";
    using(var arForm = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ARAgedRecReportSvcContract>(Db))
    {
        ARAgedRecReportTableset  arTs = arForm.GetNewParameters();
        var prRow = arTs.ARAgedRecReportParam[0];
        prRow.SelectBy="ApplyDate";
          prRow.AgeBy="DueDate";
          prRow.AgingDate=DateTime.Now;
          prRow.ARAccounts="";
          prRow.CustList="";
          prRow.SummaryOnly=false;
          prRow.AgingFormatCode="ARSyst";
          prRow.SortBy="CUSTNAME";
          prRow.CustType="B";
          prRow.CurrDesc="USD";
          prRow.CurrencyCode="USD";
          prRow.GLControlCodeList="";
          prRow.GLControlType="AR Account";
          prRow.GLControlTypeDesc="AR Account";
          prRow.SortGLControlType="AR Account";
          prRow.SortGLControlTypeDesc="AR Account";
          prRow.FiscalYear=0;
          prRow.FiscalYearSuffix="";
          prRow.FiscalPeriod=0;
          prRow.PrintSelCriteria=false;
          prRow.PrintLegNum=false;
          prRow.SortByDesc="";
          prRow.SysRowID=Guid.Parse("00000000-0000-0000-0000-000000000000");
          prRow.AutoAction="SSRSPrint";
          prRow.PrinterName="";
          prRow.AgentSchedNum=0;
          prRow.AgentID="SystemTaskAgent";
          prRow.AgentTaskNum=0;
          prRow.RecurringTask=false;
          prRow.RptPageSettings="";
          prRow.RptPrinterSettings="";
          prRow.RptVersion="";
          prRow.ReportStyleNum=r.Calculated_ReportStyle;
          prRow.WorkstationID="";
          prRow.TaskNote="";
          prRow.ArchiveCode=0;
          prRow.DateFormat="m/d/yyyy";
          prRow.NumericFormat=",.";
          prRow.AgentCompareString="";
          prRow.ProcessID="";
          prRow.ProcessCompany="";
          prRow.ProcessSystemCode="";
          prRow.ProcessTaskNum=0;
          prRow.DecimalsGeneral=0;
          prRow.DecimalsCost=0;
          prRow.DecimalsPrice=0;
          prRow.GlbDecimalsGeneral=0;
          prRow.GlbDecimalsCost=0;
          prRow.GlbDecimalsPrice=0;
          prRow.FaxSubject="AR Aging Report Requested On:" + DateTime.Today.ToShortDateString() + " via Six S Epicor Alexa Skill";
          prRow.FaxTo="";
          prRow.FaxNumber="";
          prRow.EMailTo=Db.UserFile.Where(u=>u.DcdUserID==callContextClient.CurrentUserId).FirstOrDefault().EMailAddress;
          prRow.EMailCC="";
          prRow.EMailBCC="";
          prRow.EMailBody="Attached you'll find the requested AR Aging Report. Have a pleasant day!";
          prRow.AttachmentType="PDF";
          prRow.ReportCurrencyCode="";
          prRow.ReportCultureCode="";
          prRow.SSRSRenderFormat="PDF";
          prRow.PrintReportParameters=false;
          prRow.SSRSEnableRouting=false;
   
          prRow.RowMod="A";
          arForm.SubmitToAgent(arTs,"SystemTaskAgent",0,0,"Erp.UIRpt.ARAgedRecReport");
    }
}

Then you simply do a Get, then Patch onto your BAQ from REST and you are off to the races.

var jsonResponse = RunBAQNoParamsJSON("SIXSBI-EmailAR", accessToken, log, currentCompany);
dynamic baqREslts = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonResponse);
baqREslts.value[0].RowMod = "U";
baqREslts.value[0].Calculated_ReportStyle = "2";
PatchBAQ("SIXSBI-EmailAR", accessToken, log, baqREslts.value[0], currentCompany);

Here is the End Result (Demo)

3 Likes

Not barking at all. I know of folks doing that or tying into a UD service BPM for the same thing. I’d prefer to have something more clearly defined for the scenario with better UX but it works - tons are doing it. There are some hiccups in some fringe areas that I will NOT discuss in open forums. Some advanced scenarios need advanced technical guidance :wink:

1 Like