Hi all!
I was asked, when a Quote is being marked ‘Quoted’, if I could save the PDF of that Quote in a folder on my disk.
I can do BPMs and custom.
Is this possible to do?
Thanks!
Hi all!
I was asked, when a Quote is being marked ‘Quoted’, if I could save the PDF of that Quote in a folder on my disk.
I can do BPMs and custom.
Is this possible to do?
Thanks!
I think the question is moreso “Why?” Why would you print/save something that can be reproduced at will?
I ask this for selfish reasons b/c I’ve been asked the same and they have yet to present any argument other than “We need a record of what we sent to the customer” to which my response is “it’s in your Sent Items…”
Yeah it’s the same answer I got.
“Oh in that way I would need to have an actual order in my Inobx, no way…”…
So I have to do it
I did something like this with Purchase Orders, though it’s a bit tricky to call the epicor reports in C#… You would need to investigate the Quote Report mechanisms to call and save the report. I got majority of the code off another post.
// Following routine meant to be accessed via Button from PO Screen.
//---------------------------------------------------------------------------------
// (1) Checks the PO is approved and there is an active PO on the form
// (2) Gets data from the form
// (3) Check if Approved and execute if so
// (4) Set Windows Cursor Window to “Waiting”
// (5) SQL To Retrieve Supplier Email Address -SQL Query
// (6) Call Epicor PO Form for PO Report - make the report from the PO data
// (7) Pull Down Generated Epicor Report and send to local and server directory
// (8) Send PDF to a server file (per user request…and copy to local file on user pc for emailing
// …not included for this post…(9) Open Outlook with the report as the attachment…
private void sendpo()
{
//MessageBox.Show(“ClickPO”);
// Initialize and Set variables - Cannon Specific
EpiDataView edvPOHeader = (EpiDataView)oTrans.EpiDataViews[“POHeader”];
int PONUM;
string Approved;
string Supplier;
string CurrentCompany;
string emailtext = “Please review the attached and confirm prices and delivery lead-times.”;
string supplieremailaddress= “”;
string vendorname= “”;
string strConnect = @“server=;Database=;Trusted_Connection=True;”;
string localpath = “C:/temp/”;
string username = Environment.UserName;
string serverpath = @“///”+username+“/shared/PO/”; //custom stuff -
// (1) check if there is data loaded into the form. if not return from method.
if ( (bool)edvPOHeader.HasRow == false )
{
MessageBox.Show("There is no data present to email");
return;
}
// (2) Get data from the form
Approved = (string)edvPOHeader.dataView[edvPOHeader.Row]["ApprovalStatus"];
PONUM = (int)edvPOHeader.dataView[edvPOHeader.Row]["PONum"];
Supplier = (string)edvPOHeader.dataView[edvPOHeader.Row]["VendorVendorID"];
CurrentCompany = (string)edvPOHeader.dataView[edvPOHeader.Row]["Company"];
// (3) Check if Approved
if (Approved == "A")
{
//(4) Windows Cursor Window showing "Waiting"....
Cursor.Current = Cursors.WaitCursor;
//(5) SQL To Retrieve Supplier Email Address -SQL Query
SqlConnection conn = new SqlConnection(strConnect);
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT EmailAddress from ERP.Vendor WHERE VendorID = '"+Supplier+"';", conn);
supplieremailaddress= cmd.ExecuteScalar().ToString();
SqlCommand cmd2 = new SqlCommand("SELECT Name from ERP.Vendor WHERE VendorID = '"+Supplier+"';", conn);
vendorname = cmd2.ExecuteScalar().ToString();
conn.Close();
//(6) -- Call Epicor PO Form for PO Report - make the report from the PO data
Erp.Proxy.Rpt.POFormImpl poform = WCFServiceSupport.CreateImpl<Erp.Proxy.Rpt.POFormImpl>
((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Erp.Contracts.POFormSvcContract>.UriPath); //poform is the object for PO methods
Guid MyReportGuid = Guid.NewGuid(); // Create a GUID ID to track the report later after generation.
Erp.Rpt.POFormDataSet POFts = null; // Do a PO Form Data Set to work with (named here as POFTS)
POFts = poform.GetNewParameters();
POFts.POFormParam[0].AgentID = "SystemTaskAgent"; //Set Parameters....
POFts.POFormParam[0].AutoAction = "SSRSGenerate";
POFts.POFormParam[0].DateFormat = "dd/MM/yy";
POFts.POFormParam[0].ArchiveCode = 1;
POFts.POFormParam[0].SSRSRenderFormat = "PDF";
POFts.POFormParam[0].PONum = PONUM;
POFts.POFormParam[0].ReportStyleNum = 1001; // Set to Custom Report form
POFts.POFormParam[0].TaskNote = String.Format("{0}",MyReportGuid); //Set the Task Note to the Tracking GUID
//MessageBox.Show("Run Direct ...");
poform.RunDirect(POFts); //Runs report - waits until finished/hangs.
// Go Grab the Generated report, send to file system.
//MessageBox.Show("Getting Report from Database...");
string strMyReportGuid = String.Format("{0}",MyReportGuid);
//(7) Pull Down Generated Epicor Report and send to local and server directory
// SQL - Pull down report using Tracking GUID
conn.Open();
SqlCommand cmd3 = new SqlCommand("SELECT rptdata from Ice.SysRptLst WHERE RptNote='"+strMyReportGuid+"';", conn);
byte[] results = (byte[])cmd3.ExecuteScalar();
string localfile = localpath+PONUM+" - "+vendorname+".pdf";
string serverfile = serverpath+PONUM+" - "+vendorname+".pdf";
conn.Close();
//(8) Send PDF to a server file (per user request...and copy to local file on user pc for emailing
//Debug MessageBox.Show(@serverfile);
if(Directory.Exists(@serverpath))
System.IO.File.WriteAllBytes(@serverfile, results);
if(Directory.Exists(@localpath))
System.IO.File.WriteAllBytes(@localfile, results);
else
{
MessageBox.Show("Please create a "+@localpath+" directory ");
return;
}
Cursor.Current = Cursors.Default;
}
else
MessageBox.Show("PO must be approved before it can be sent out");
}