Print ARForm from custom button error


Did a trace in Epicor 9.05 and using visual studio 2013 I automated all the bo's to print from the job trveller.

 

My code compiled and stepped through but nothing was sent to the printer. Has anyone seen this issue before? AM i missing someting?

 

Below are all the bo's I used:

 

Epicor.Mfg.BO.Menu

Epicor.Mfg.BO.SysAgent

Epicor.Mfg.BO.SysAgent

Epicor.Mfg.Lib.ClassAttribute

Epicor.Mfg.BO.ProcessSet

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.Lib.ClientFunctions

Epicor.Mfg.Lib.BOReader

Epicor.Mfg.BO.GenXData

Epicor.Mfg.BO.GenXData

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.BO.JobEntry

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Unable to cast object of type 'System.String' to type 'System.Data.DataRow'.

 

I have code that is writing an Invoice number to a text box when a cell is clicked. There can be multiple values in this text box. I get above error when clicking the button with this code behind it.

 

private void btnPrintInvoice_Click(object sender, System.EventArgs args)
 {
  // ** Place Event Handling Code Here **
  //Print Invoices
  if(printInvoices.Text != "")
  {
   string printlist = printInvoices.Text;
   for(int i=0; i<printlist.Split('\n').Length; i++)
   {
    ProcessCaller.LaunchForm(oTrans, "ARGL3007", printlist.Split('\n')[i]);
   }
  }
 }

You are passing an array of strings to the process caller.. which it dosn't understand.



Jose C Gomez
Software Engineer



T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com

     Â


Quis custodiet ipsos custodes?


On Mon, Dec 9, 2013 at 11:20 AM, <livingstonmh@...> wrote:

Â
<div>
  
  
  <p></p><p>Unable to cast object of type &#39;System.String&#39; to type &#39;System.Data.DataRow&#39;.</p><p>Â </p><p>I have code that is writing an Invoice number to a text box when a cell is clicked. There can be multiple values in this text box. I get above error when clicking the button with this code behind it.</p>

Â

private void btnPrintInvoice_Click(object sender, System.EventArgs args)
 {
  // ** Place Event Handling Code Here **
  //Print Invoices
  if(printInvoices.Text != "")
  {
   string printlist = printInvoices.Text;

   for(int i=0; i<printlist.Split('\n').Length; i++)
   {
    ProcessCaller.LaunchForm(oTrans, "ARGL3007", printlist.Split('\n')[i]);
   }
  }
 }

</div>
 


<div style="color:#fff;min-height:0;"></div>

isn't  for(int i=0; i<printlist.Split('\n').Length; i++) basically only sending 1 at a time though? If the text box has 2 values in it then I get 2 errors.

Even if this opened multiple forms for each invoice that I am passing would be ok with us.

 

I even tried just having it open the invoice tracker, but this will not open multiple windows, and just takes the last invoice passed.

Or if anyone has experience with the ARInvFormAdapter that would be fantastic. I have tried using it, but I can not get it to work with the below code:

private void CallARInvoiceAdapterGetByIDMethod(string invoiceNum)
 {
  try
  {
   // Declare and Initialize EpiDataView Variables
   // Declare and create an instance of the Adapter.
   ARInvoiceAdapter adapterARInvoice = new ARInvoiceAdapter(this.oTrans);
   adapterARInvoice.BOConnect();

   // Declare and Initialize Variables

   // Call Adapter method
   bool result = adapterARInvoice.GetByID(Convert.ToInt32(invoiceNum));
   ARInvoiceDataSet ds = adapterARInvoice.ARInvoiceData;
   
   ARInvFormAdapter adapterform = new ARInvFormAdapter(this.oTrans);
   adapterform.BOConnect();
   adapterform.GetDefaults();
   adapterform.GetNewParameters();
   adapterform.PackNumDefaults();
   
   string agentID = "SystemTaskAgent";
   int agentSchedNum = 0;
   int agentTaskNum = 0;
   string maintProgram = "Epicor.Mfg.UIRpt.ARInvForm";
   adapterform.SubmitToAgent(agentID,agentSchedNum,agentTaskNum);
   // Cleanup Adapter Reference
   adapterARInvoice.Dispose();
   
  } catch (System.Exception ex)
  {
   ExceptionBox.Show(ex);
  }

So are you trying to open the Invoice form or to print the ARForm report? I see a little of both in there and this is one where the names can get quite confusing.

If you are trying to print, then I think you may be using the wrong objects. You need the rpt object and its associated dataset. Here is an example of going to print preview of a traveller report.

private void btnPrintTraveler_Click(object sender, System.EventArgs args)
    {
        // ** Place Event Handling Code Here **
        Epicor.Mfg.Core.Session epiSession = default(Epicor.Mfg.Core.Session);
        epiSession = (Epicor.Mfg.Core.Session)UD01Form.Session;
        Epicor.Mfg.Rpt.JobTrav rptJobTrav = new Epicor.Mfg.Rpt.JobTrav(epiSession.ConnectionPool);
        Epicor.Mfg.Rpt.JobTravDataSet rptDSJobTrav = rptJobTrav.GetNewParameters();

        EpiDataView edvBPMData  = ((EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]));

        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["Jobs"] =edvBPMData.dataView[edvBPMData.Row]["ShortChar01"];
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["Assembly"] = edvBPMData.dataView[edvBPMData.Row]["Character02"];
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["PrntAllMassPrnt"] = false;
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["BarCodes"] = true;
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["SubAssem"] = false;       
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["AutoAction"] = "Preview";

        //Set Task Agent
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["AgentID"] = "SystemTaskAgent";

        //Report Style
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["ReportStyleNum"] = 1001;
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["WorkStationID"] = Environment.MachineName + " " + userName;
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["DateFormat"] = "mm/dd/yyyy";
        rptDSJobTrav.Tables["JobTravParam"].Rows[0]["NumericFormat"] = ",.";

        //Submit to Task Agent
        rptJobTrav.SubmitToAgent(rptDSJobTrav, "SystemTaskAgent",0,0,"Epicor.Mfg.UIRpt.JobTrav");

    }


Feel free to give me a shout if you have any questions.

All I can say is simply thank you. This is exactly what I needed. For the future, is there a place to find what syntax is needed for these? The Rpt Dll files do not show in the adapter list for Object Explorer so I was going blind


Good Day Jose. I am trying to automate the Job Traveler in epicor to print using Visual Studio.

 

Is this possible? 

Yes it is possible


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Mon, Feb 2, 2015 at 9:31 AM, cyrilz199@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><p><br>Good Day Jose. I am trying to automate the Job Traveler in epicor to print using Visual Studio.</p><p> </p><p>Is this possible?  </p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

So, I did a trace and below are all the BO it used to spit out a crystal report for the job traveller.

From your examples, you guys identified that to print it only needs the Epicor.Mfg.Rpt.JobTrav BO.

Is this so or do I need to call all the BO's on the list? that will be a lot of dll to add to my C# application.

 

Epicor.Mfg.BO.Menu

Epicor.Mfg.BO.SysAgent

Epicor.Mfg.BO.SysAgent

Epicor.Mfg.Lib.ClassAttribute

Epicor.Mfg.BO.ProcessSet

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.Lib.ClientFunctions

Epicor.Mfg.Lib.BOReader

Epicor.Mfg.BO.GenXData

Epicor.Mfg.BO.GenXData

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.BO.JobEntry

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.JobAsmSearch

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.Rpt.JobTrav

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor

Epicor.Mfg.BO.ReportMonitor