SO check if Emailing or Printing  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

SO check if Emailing or Printing

Postby 2can2 » Mon Jun 11, 2018 3:44 pm

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.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: SO check if Emailing or Printing  Topic is solved

Postby DannyC » Mon Jun 11, 2018 7:31 pm

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
User avatar
DannyC
Senpai
Senpai
 
Posts: 656
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: SO check if Emailing or Printing

Postby 2can2 » Tue Jun 12, 2018 8:29 am

Hi, thanks Danny. By skipping the save does the PrintLog still get updated?
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: SO check if Emailing or Printing

Postby SBarnes » Tue Jun 12, 2018 4:05 pm

Yes the print log will still get written to, that's in the print code.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1646
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 182

Re: SO check if Emailing or Printing

Postby 2can2 » Wed Jun 13, 2018 10:39 am

Thanks you both.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: SO check if Emailing or Printing

Postby 2can2 » Wed Jun 13, 2018 1:19 pm

This code worked a treat for Printing.
Any ideas on how I do the same for emailing?
Cheers
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: SO check if Emailing or Printing

Postby DannyC » Thu Jun 14, 2018 5:15 pm

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 656
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: SO check if Emailing or Printing

Postby 2can2 » Fri Jun 15, 2018 1:58 pm

Thanks Danny. Will give it a try.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests