Sales Order printed, then email
I want to do an email after a delivery docket has been printed.
I am exploiting some code in the "Sales Order Custom Email" plugin you've written - basically I want to fire the
I need to pass the SalesOrderForm object into the Private Sub EmailSalesOrder but I can't work out how to do it.
So far I have
but I clearly have a mix up between the object types. It seems the sender in the SOPrinted sub is not a form so it can't cast to a form type.
When I print, I get an error
unable to cast object of type JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder to type JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm.
How can I get the SalesOrderForm object to pass into the EmailSalesOrder sub?
Thanks
Danny
I am exploiting some code in the "Sales Order Custom Email" plugin you've written - basically I want to fire the
- Code: Select all
Private Sub EmailSalesOrder
I need to pass the SalesOrderForm object into the Private Sub EmailSalesOrder but I can't work out how to do it.
So far I have
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
AddHandler salesOrderForm.SalesOrder.Printed, AddressOf SOPrinted
End Sub
Public Sub SOPrinted (sender As Object, e As System.eventargs, ByVal Report As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)
If Report.Name = "Delivery Docket" Then
' msgbox ("You have printed the delivery docket")
Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(sender, JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
EmailOrderConfirmation(salesOrderForm)
Throw New JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException
End If
End Sub
'''''''''''''
Private Sub EmailOrderConfirmation(ByVal SalesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm, Optional ByVal ExportFormatType As CrystalDecisions.Shared.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
If salesOrderForm.SalesOrder.ChangeFlag Or salesOrderForm.SalesOrder.InsertFlag Then
Throw New System.Exception("Cannot email a sales order until the changes have been saved.")
End If
'''This is the same as the Jiwa code
End Sub
but I clearly have a mix up between the object types. It seems the sender in the SOPrinted sub is not a form so it can't cast to a form type.
When I print, I get an error
unable to cast object of type JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder to type JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm.
How can I get the SalesOrderForm object to pass into the EmailSalesOrder sub?
Thanks
Danny