When our users are done entering a sales order they want to send a order acknowledgement via email. We want to use the standard SSRS email option under the Print menu (see screen shot) but pre-filled in Subject, To, and email Body.
I’ve done a trace but the method it shows can’t be found. Any ideas where to look?
Was trying another route of using AutoPrint. Can variables be referenced in a auto print email message? I get an error when I try to use the variable I have setup for the customer’s email address.
I’m downloading Visual Studio 2015 from microsoft now as well, hopefully it’ll make my life easier and I can learn more coding and be more helpful around here answering questions instead of asking them.
Ok, I’m close. Just a few error I can’t seem to figure out. Looks like an assembly but I’m not sure how to add it or what it is. Running a new trace log to see if it’ll help.
Thanks for the correction. Guess I pulled too much out of the tracelog as I got both from the trace. Still missing something, I think it’s a reference but I’ve added the ones I think it’d need, am I missing some?
System.Drawing.Bitmap CS0246 The type or namespace name ‘SalesOrderAckTableSet’ could not be found (are you missing a using directive or an assembly reference?)
System.Drawing.Bitmap CS0246 The type or namespace name ‘SOFormParamRow’ could not be found (are you missing a using directive or an assembly reference?)
Can you share the code for this? I’d like to see if I can get it going on my side as well.
I attacked a similar idea in a different way. We purchased “SSRS Advanced Routing/Breaking” module recently so I’m using that to generate the print. So my BPM checks for the correct conditions on when to fire and then i’m using the “Auto Print” widget to send the print job over to SSRS Routing/Breaking.
If I generate a print from the BPM “Custom Code”, then I may not need to use the “Auto Print” widget to hand the print over to SSRS Routing/Breaking to generate the document. It may save a step. However, if I stick with the current method, I wouldn’t need to write any custom code! Decisions!
Ideally, I want to print a BAQReport from the custom code but I’m not very well versed in C# so that will have to happen another time!
Ah ha! I wasn’t declaring the variables! I did mention I’m not a coder, right? Which is why I knew it was something stupid and easy I was missing.
Looking over your code I can tell there is much more I was missing, like converting the data types (Boolean, etc) and everything from your “Run immediately” line.
I wish I could give more than one Solution checkbox both you and Jose deserve one!
I appreciate the help guys I feel bad for not getting this going myself. The code is pretty much a copy/paste of Ken’s. I’ve verified the report style ID, Epi User/Pass (I’m using a “system agent” one we have not “manager”.
var reportParamTS = new Erp.Tablesets.SalesOrderAckTableset();
var reportParamRow = new Erp.Tablesets.SalesOrderAckParamRow();
reportParamTS.SalesOrderAckParam.Add(reportParamRow);
int rowIndex = 0;
var primaryTableRow = ttOrderHed.Where(tt=>tt.Updated()).FirstOrDefault();
if(primaryTableRow != null)
{
reportParamRow.OrderNum = primaryTableRow.OrderNum;
reportParamRow.ArchiveCode = Convert.ToInt32("0");
reportParamRow.PrintReportParameters = Convert.ToBoolean("False");
reportParamRow.SSRSEnableRouting = Convert.ToBoolean("False");
reportParamRow.AutoAction = "SSRSPrint" ;
reportParamRow.ReportStyleNum = 1002 ; // Our StyleID
reportParamRow.WorkstationID = "MYWorkStation";
reportParamRow.TaskNote = "SO_Ack";
// if (reportParamTS.SalesOrderAckParam.Columns.Contains("EmailTo"))
// {
reportParamRow.FaxTo = "";
reportParamRow.FaxNumber = "";
reportParamRow.FaxSubject = "The order " + primaryTableRow.OrderNum + " has been created from PO: " + primaryTableRow.PONum;
reportParamRow.EMailTo = CustEmail; // BPM variable
reportParamRow.EMailCC = "";
reportParamRow.EMailBCC = "";
reportParamRow.EMailBody = "Please see the attached sales acknowledgement for order " + primaryTableRow.OrderNum + " which was created from PO: " + primaryTableRow.PONum;
reportParamRow.AttachmentType = "PDF";
reportParamRow.RowMod = "A";
reportParamRow.SSRSRenderFormat = "PDF";
// }
// Run immediately
try
{
reportParamRow.AgentID = ""; /* Clear the Agent fields when running direct */
reportParamRow.AgentSchedNum = 0;
reportParamRow.AgentTaskNum = 0;
// Using this method will not block the thread
object[] outParam = null;
Ice.Hosting.ServiceCaller.Execute("Erp:Rpt:SalesOrderAck", "WriteSysTask", new System.Collections.Specialized.NameValueCollection(), new object[]{reportParamRow}, out outParam);
int sysTaskNum = Convert.ToInt32(outParam[0]);
// Decrypt the password
var password = Epicor.Security.Cryptography.Encryptor.DecryptToString( "ThePaswordHere" );
// Create the TaskLauncher instance.
var taskLauncher = new Ice.Hosting.TaskLauncher();
System.Threading.Tasks.Task launchingTask = new System.Threading.Tasks.Task(() => {taskLauncher.CallTask( "EpiUserNameHere" , password, sysTaskNum);});
launchingTask.Start();
}
catch (Exception ex)
{
}
rowIndex++;
}