V6 to V7 breakout/plugin conversion  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

V6 to V7 breakout/plugin conversion

Postby Atronics » Thu Nov 19, 2015 10:21 am

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.
Atronics
Frequent Contributor
Frequent Contributor
 
Posts: 119
Joined: Fri Feb 29, 2008 4:40 pm
Topics Solved: 10

Re: V6 to V7 breakout/plugin conversion  Topic is solved

Postby Mike.Sheen » Thu Nov 19, 2015 9:25 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: V6 to V7 breakout/plugin conversion

Postby Atronics » Wed Nov 25, 2015 9:10 am

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
Atronics
Frequent Contributor
Frequent Contributor
 
Posts: 119
Joined: Fri Feb 29, 2008 4:40 pm
Topics Solved: 10

Re: V6 to V7 breakout/plugin conversion

Postby Mike.Sheen » Mon Dec 07, 2015 10:21 am

Answered in another post: viewtopic.php?f=26&t=488
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 2 guests