Creating my first function

I just wanted to update on here that I now have this working. I am still having problems with server log messages displaying in Live and Test and have an open case with Epicor for that but I now have a function that will use a BAQ to identify which parts we want to check out and then a scheduled function to action it.

It really helped finding out that the Kinetic screen has a Mass Check Out option in the Engineering Workbench which we have never used before. The main help came from this forum post:

And this is my code :slight_smile:

// Checks out all Part Revisions that have not been approved within the last 6 months (183 days) or invoiced in the system or within the same date range


string baqName = "Parts-RevAutoCheckOut1";  // BAQ Name

CallService<DynamicQuerySvcContract>(dq =>
{
  Ice.Tablesets.QueryExecutionTableset qets = new Ice.Tablesets.QueryExecutionTableset(); 
  DataSet ds = dq.ExecuteByID(baqName, qets);
  
  if(ds != null)
  {
  
  if(ds.Tables.Count > 0)
  {
        
    this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(engWBSVC =>
    {
      //declare tablesets
      //var engDS = new Erp.Tablesets.EngWorkBenchTableset();
      var engDSMass = new Erp.Tablesets.MassCheckoutTableset();
      
      try
      {
            
        foreach(DataRow drRow in ds.Tables[0].Rows)
        {
                    
          var massCheckoutTS = (Erp.Tablesets.MassCheckoutRow)engDSMass.MassCheckout.NewRow();
          massCheckoutTS.Company = this.BaqConstants.CurrentCompany;
          massCheckoutTS.CreateNewRev = false;
          massCheckoutTS.GroupID = "Hold-NotShipped6m";
          massCheckoutTS.PartNum = drRow["Part_PartNum"].ToString();
          massCheckoutTS.RevisionNum = drRow["PartRev_RevisionNum"].ToString();
          massCheckoutTS.SourcePartNum = drRow["Part_PartNum"].ToString();
          massCheckoutTS.SourceRevisionNum = drRow["PartRev_RevisionNum"].ToString();;
          massCheckoutTS.RevShortDesc = "Import Rev";
          massCheckoutTS.SysRowID = Guid.NewGuid();
          massCheckoutTS.RowMod = "A";
          
          engDSMass.MassCheckout.Add(massCheckoutTS);
          
        }
      
        engWBSVC.ProcessMassCheckout(ref engDSMass);
        
      }
        catch
        {
        }      
      
      });
    }
  }
});
7 Likes