Call an Epicor Function asynchronously

I made a function to make this easier. I am using this currently for an automated process I have running after packs are marked shipped.

(Note, this function schedules for immediate run, it needs to be modified to do at a real scheduled time.)

Function: ScheduleFunction
Signature: IN

  • libraryID → System.String
  • functionID → System.String
  • parametersJson → System.String
try
{
    CallService<Ice.Contracts.ScheduledFunctionSvcContract>(sf=>
    {
        ScheduledFunctionsTableset sfTS = new ScheduledFunctionsTableset();
        sf.GetDefaults(ref sfTS);
      
        ScheduledFunctionParamRow paramRow = sfTS.ScheduledFunctionParam.FirstOrDefault();
      
        paramRow.LibraryId = libraryID;
        paramRow.FunctionId = functionID;
        paramRow.ParameterValues = parametersJson;
        paramRow.RowMod = "A";
        
        sf.SubmitToAgent(sfTS, "SystemTaskAgent", 0, 0, "Ice.Services.Proc.ScheduledFunction");
    });
}
catch (Exception ex)
{}

It can be called like:

Dictionary<string, object> scheduledFunctionParametersDictionary = new Dictionary<string, object>();

scheduledFunctionParametersDictionary.Add("inputParamYouNeed1", whatyouaresendingforthisinputparam);
          
InvokeFunction("LibYouPutThisIn", "ScheduleFunction", "FunctionLibraryToCall", "FunctionToCall", JsonConvert.SerializeObject(scheduledFunctionParametersDictionary));

Edit, I had in error in the usage code, corrected.

6 Likes