Custom Emails

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

Custom Emails

Postby Ernst » Tue Aug 25, 2026 2:11 pm

In JIWA7 we had plugins for adjusting the email subject message etc e.g. "Sales Order Custom Email,Purchase Order Custom Email" DO we have any similar ones in JIWA8?
User avatar
Ernst
Kohai
Kohai
 
Posts: 254
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 14

Re: Custom Emails

Postby Mike.Sheen » Tue Aug 25, 2026 2:13 pm

Ernst wrote:In JIWA7 we had plugins for adjusting the email subject message etc e.g. "Sales Order Custom Email,Purchase Order Custom Email" DO we have any similar ones in JIWA8?


No, a plugin could do that, but we thought with the Email Templates you wouldn't need a plugin to do that - the template you select does that instead.
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: 2631
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 827

Re: Custom Emails

Postby Ernst » Tue Aug 25, 2026 2:45 pm

OK I see I guess that works well, So once you select a template then it remembers it for next time.
We had quite a few scheduled emails also. e.g. to send Invoices each night, or to send out reports. See attached example.
Would this still work in JIWA8, Having trouble with Plugin.Manager.ResetReportSelectionFormulaTokens, and Plugin.Manager.AddReportSelectionFormulaToken


Plugin Accent Email - Sales with COGS report.xml
(85.1 KiB) Downloaded 577 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 254
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 14

Re: Custom Emails

Postby Mike.Sheen » Tue Aug 25, 2026 4:50 pm

EmailReportDirect now wants a couple of dictionary parameters - ReportFormulas and ReportReplacementTokens - here is the signature:

Code: Select all
public void EmailReportDirect(JiwaFinancials.Jiwa.JiwaApplication.Report.Configuration.Report Report, string From, string EmailTo, string Subject, string CC, string BCC, string Message, string NameToGiveAttachment, ref string EM_Main_RecID, System.Collections.Generic.Dictionary<string, string> ReportFormulas = null, System.Collections.Generic.Dictionary<string, string> ReportReplacementTokens = null, bool RequestReadReceipt = false, string SourceID = "", string SourceType = "", string SourceDisplayNo = "", JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes SourceDrillDownIndex = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswUnknown, JiwaFinancials.Jiwa.JiwaApplication.JiwaReportProvider.ExportFormats ExportFormatType = JiwaFinancials.Jiwa.JiwaApplication.JiwaReportProvider.ExportFormats.PortableDocFormat, string SY_Forms_ClassName = "")


So instead of:

Code: Select all
Plugin.Manager.AddReportSelectionFormulaToken("{@PASS_FromAcc}", emailCandidate.DebtorStart)


You will want to create a dictionary for either or both ReportFormulas and ReportReplacementTokens, set the values and pass to the EmailReportDirect method.

ReportFormulas is for replacing the Crystal Report entirely with the provided value, ReportReplacementTokens will inspect formulas and replace parts of the formula matching the token key with the corresponding value.

From the look of your plugin, you're wanting to just set Crystal Formula contents, not a token replacement, so to just create a formula dictionary and add some values and pass that to EmailReportDirect, you would do:
Code: Select all
Dim formulas As New Dictionary(Of String, String)
formulas["{@PASS_FromAcc}"] = emailCandidate.DebtorStart ' Just setting a dictionary value will add it, or replace it if already present - no need to formally use Add
formulas["{@PASS_ToAcc}"] = emailCandidate.DebtorEnd
// And so on
Plugin.Manager.EmailReportDirect(reportToEmail, "admin@accent-tools.co.nz", emailCandidate.EmailAddress, message, emailCandidate.CCEmailAddress, "", message, FileName, EM_Main_RecID, formulas, null, "", False, sourceID, sourceType, sourceDisplayNo, sourceDrillDownIndex, exportFormatType);
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: 2631
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 827

Re: Custom Emails

Postby Ernst » Fri Sep 04, 2026 4:54 pm

thx will give it a go..:)
User avatar
Ernst
Kohai
Kohai
 
Posts: 254
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 14

Re: Custom Emails

Postby Ernst » Tue Sep 22, 2026 1:24 pm

HI Mike, OK adjusted report to use the Formula method. But the report wont run under the plugin. The plugin just keeps reloading and reloading. Without actually running. I set up a test to just run the standard debtor report and same thing. Is the running of report to email working. Have just updated to 8.0.63?

report with formula
Plugin Accent Email - Sales with COGS report.xml
(90.28 KiB) Downloaded 4 times


Test plugin running standard report
Plugin Accent Email - Sales with COGS report.xml
(90.28 KiB) Downloaded 4 times


CaptureEventRunsAgainandAgain.JPG
Attachments
Plugin Accent Email - Test Send Report.xml
(57.58 KiB) Downloaded 6 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 254
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 14

Re: Custom Emails

Postby Mike.Sheen » Tue Sep 22, 2026 4:20 pm

Of course emailing with report attachments works - we use it daily.

Way too much noise in your first two example plugins for me to be able to troubleshoot - your attached plugin "Accent Email - Test Send Report" I was able to troubleshoot with a some effort.

My journey was as follows:

1. Imported plugin, inspected code and discovered that I had to modify it to use my email address(es) for sender and recipient, noted also I needed to alter the schedule because it was set once daily at 8am and I was not about to wait for that to happen.
2. Setup my system for emailing and the plugin scheduler service, verified emailing worked normally using Email Maintenance form, started Plugin Scheduler service
3. Noted that there was no error logged to event log, but no email came - did see events indicating the plugin scheduler was running the plugin on schedule.
4. Turned on LogApplicationEvents in Jiwa so the errors are logged, restarted plugin scheduler.
LogApplicationEvents.png
LogApplicationEvents.png (2.69 KiB) Viewed 167 times

5. Could now see in the event log an error - "Conversion from string "" to type 'Boolean' is not valid'
EventLogError.png

6. Examined plugin, using intellisense saw that there was an extra parameter being passed to EmailReportDirect - a literal "" which should not be there.
Changed
Code: Select all
Plugin.Manager.EmailReportDirect(reportToEmail, "sender@example.com", "recipient@example.com", message, "", "", message, "StockOut.PDF", EM_Main_RecID,Nothing , Nothing,"", False, sourceID, sourceType, sourceDisplayNo, sourceDrillDownIndex, exportFormatType)

To
Code: Select all
Plugin.Manager.EmailReportDirect(reportToEmail, "sender@example.com", "recipient@example.com", message, "", "", message, "StockOut.PDF", EM_Main_RecID,Nothing , Nothing, False, sourceID, sourceType, sourceDisplayNo, sourceDrillDownIndex, exportFormatType)

7. Restarted service
8. Now observed a new, different, error - That the Crystal Formula Pass_SP_FromDate had an invalid date value
EventLogError_2.png

9. Opened report SOMGT051 - Sales with COGS by Debtor.rpt, examined formula - removed spaces, saved report
10. In Jiwa, opened report maintenance and freshed the report SOMGT051 - Sales with COGS by Debtor.rpt, saved
11. Deleted cached report in ProgramData\Jiwa Financials\Jiwa 8\8.0.63... folder just in case
12. Restarted Plugin Scheduler service
13. Received email with report as attachment.

So in this specific instance the problem was 1. your call to EmailReportDirect had an extra parameter, and 2. The report SOMGT051 - Sales with COGS by Debtor.rpt had spaces in the Crystal Formula our engine did not like

I've logged DEV-13084 to adjust our report engine to tolerate those spaces - but you can work-around that before then either by editing the report and removing them as I did, or in your plugin creating a ReportFormulas dictionary, adding an entry for the Pass_SP_FromDate and passing that dictionary to EmailReportDirect.
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: 2631
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 827


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests