V6 to V7 breakout/plugin conversion

Posted:
Thu Nov 19, 2015 10:21 am
by Atronics
How do I include sending a CC email in Sales Orders emailing. The following is from a V6 breakout.
If SalesOrderObject.DebtorID = "000000000I000000003J" Then
CC = "
[email protected];
[email protected]"
End If
All my efforts in the plugin have failed.
Re: V6 to V7 breakout/plugin conversion 

Posted:
Thu Nov 19, 2015 9:25 pm
by Mike.Sheen
Atronics wrote:How do I include sending a CC email in Sales Orders emailing. The following is from a V6 breakout.
If SalesOrderObject.DebtorID = "000000000I000000003J" Then
CC = "
[email protected];
[email protected]"
End If
All my efforts in the plugin have failed.
We ship with a plugin named "Sales Order Custom Email" - you can copy that plugin (And by copy, I mean load the plugin using the plugin maintenance form and choose the "Copy" tool in the ribbon under the "Actions" group), and then enable that, then in around line 68 just add:
- Code: Select all
If salesOrderForm.SalesOrder.Debtor.DebtorID = "000000000I000000003J" Then
emailReportDialog.CC = "[email protected]; [email protected]"
End If
NOTE: If the "Sales Order Custom Email" plugin is already enabled, you will need to disable that for your copied plugin to work, as the existing "Sales Order Custom Email" plugin will cancel the tool_click event and no other plugins (including your copied one) will get the tool_click event for emailing as it issues a ClientCancelled exception to cause a silent failure preventing any further processing of the tool_click event.
Mike
Re: V6 to V7 breakout/plugin conversion

Posted:
Wed Nov 25, 2015 9:10 am
by Atronics
Thanks for the prompt response, Mike. I now need to enhance the emailing based on Contact Positions. The following breakout which uses the spEmailAddress works in V6 but I am struggling to find the relevant event handlers. Can you point me in the right direction for V7
*********************** V6 Breakout
'Form Email Invoice Clicked - Modified By Atronics 07/12/2006
'Last Modified :- 26/09/2011
Dim ReadHandle
Dim SQL
With SalesOrderObject.Database
ReadHandle = .StatementOpen(.ConnectionRead1, False, "", 0)
SQL = "EXEC spEmailAddress '" & SalesOrderObject.DebtorID & "', 'Email Invoice'"
If .ExecuteSelect(CInt(ReadHandle), CStr(SQL)) <> 0 Then
.BindMem CInt(ReadHandle), 1, vbString
If .FetchRow(CInt(ReadHandle)) = True Then
EmailTo = .getData(CInt(ReadHandle), 1)
End If
End If
.StatementRenew CInt(ReadHandle)
If EmailTo = "" Then
MsgBox("No email address on file. Email cancelled")
rtnCancel = True
Else
SQL = "EXEC spEmailAddress '" & SalesOrderObject.DebtorID & "', 'CC Email Invoice'"
If .ExecuteSelect(CInt(ReadHandle), CStr(SQL)) <> 0 Then
.BindMem CInt(ReadHandle), 1, vbString
If .FetchRow(CInt(ReadHandle)) = True Then
CC = .getData(CInt(ReadHandle), 1)
End If
End If
End If
.StatementRenew CInt(ReadHandle)
.StatementClose CInt(ReadHandle)
Subject = "Invoice From Advanced Seed"
NameToGiveAttachment = "Invoice " & SalesOrderObject.InvoiceNo & "-D0" & CStr(SalesOrderObject.SelectedHistoryNo)
Message = "Thank you for your order. Please find our invoice attached" & vbCrLf & vbCrLf & _
"Kind Regards" & vbCrLf & _
SalesOrderObject.Database.JiwaLoginUserName
End With
End Sub
***************************spEmailAddress
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[spEmailAddress]
(@DebtorID char(20),
@Position varchar(50))
AS
Declare @EmailAddress varchar(200)
Select Top 1 @EmailAddress = cc.EmailAddress
From CN_Contact cc, CN_Main cm, CN_ContactPosition cp1
Where cc.ProspectID = cm.ProspectID
And cm.DebtorID = @DebtorID
And cc.PrimaryID = cp1.ContactPositionID
And cp1.Position = @Position
If @EmailAddress Is Null
Select Top 1 @EmailAddress = cc.EmailAddress
From CN_Contact cc, CN_Main cm, CN_ContactPosition cp2
Where cc.ProspectID = cm.ProspectID
And cm.DebtorID = @DebtorID
And cc.SecondaryID = cp2.ContactPositionID
And cp2.Position = @Position
If @EmailAddress Is Null
Select Top 1 @EmailAddress = cc.EmailAddress
From CN_Contact cc, CN_Main cm, CN_ContactPosition cp3
Where cc.ProspectID = cm.ProspectID
And cm.DebtorID = @DebtorID
And cc.TertiaryID = cp3.ContactPositionID
And cp3.Position = @Position
Select EmailAddress = IsNull(@EmailAddress, '')
GO
Re: V6 to V7 breakout/plugin conversion

Posted:
Mon Dec 07, 2015 10:21 am
by Mike.Sheen
Answered in another post:
viewtopic.php?f=26&t=488