Page 1 of 1
SO check if Emailing or Printing
Posted:
Mon Jun 11, 2018 3:44 pm
by 2can2
Hi, In V175 using VB in a custom Plugin for SO's I want to skip my checks on SAVE if the SO is being Emailed or Printed.
I have used 'IF NOT SO.InvoiceEmailed' but this checks if the SO has been emailed previously not if you are emailing currently.
Can you give me the necessary syntax please. Thanks.
Re: SO check if Emailing or Printing
Posted:
Mon Jun 11, 2018 7:31 pm
by DannyC
This is what I've done previously when I don't want the save event to fire when printing
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaApplication.IJiwaForm)
AddHandler salesOrderForm.SalesOrder.SaveEnding, AddressOf SO_SaveEnding
AddHandler salesOrderForm.SalesOrder.PrintingMany, AddressOf SalesOrder_PrintingMany
AddHandler salesOrderForm.SalesOrder.PrintedMany, AddressOf SalesOrder_PrintedMany
End Sub
Private Sub SalesOrder_PrintingMany(sender As Object, e As System.EventArgs, ByRef ReportCollection As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport))
' We remove the handler so we don't listen to the save just because we are printing
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
RemoveHandler salesOrder.SaveEnding, AddressOf SO_SaveEnding
End Sub
Private Sub SalesOrder_PrintedMany(sender As Object, e As System.EventArgs, ReportCollection As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport))
' We add back the handler after printing
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
AddHandler salesOrder.SaveEnding, AddressOf SO_SaveEnding
End Sub
Sub SO_SaveEnding (sender As Object, e As System.eventargs)
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
' Do your code here
End Sub
Re: SO check if Emailing or Printing
Posted:
Tue Jun 12, 2018 8:29 am
by 2can2
Hi, thanks Danny. By skipping the save does the PrintLog still get updated?
Re: SO check if Emailing or Printing
Posted:
Tue Jun 12, 2018 4:05 pm
by SBarnes
Yes the print log will still get written to, that's in the print code.
Re: SO check if Emailing or Printing
Posted:
Wed Jun 13, 2018 10:39 am
by 2can2
Thanks you both.
Re: SO check if Emailing or Printing
Posted:
Wed Jun 13, 2018 1:19 pm
by 2can2
This code worked a treat for Printing.
Any ideas on how I do the same for emailing?
Cheers
Re: SO check if Emailing or Printing
Posted:
Thu Jun 14, 2018 5:15 pm
by DannyC
For emailing I suggest trying this
- Code: Select all
AddHandler salesOrderForm.SalesOrder.Emailing, AddressOf SalesOrder_EmailingMany
AddHandler salesOrderForm.SalesOrder.Emailed, AddressOf SalesOrder_EmailedMany
And just pop in similar code for remove & add in the handler.
Re: SO check if Emailing or Printing
Posted:
Fri Jun 15, 2018 1:58 pm
by 2can2
Thanks Danny. Will give it a try.