Automating Jiwa from command line or script or other  Topic is solved

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

Automating Jiwa from command line or script or other

Postby DannyC » Wed Jun 15, 2016 5:13 pm

Hi,

Version 7.0.129
Language: VB .Net

My situation:

I need to send an order confirmation automatically when a new sales order is saved in Jiwa without any user intervention (aside from a question "Would you like to send an order confirmation?").
I've found that I can only detect a new sales order on the SaveStart event. But if I send an email from that event, it needs the sales order saved first so I'm in a Catch 22.
So what I am doing as a workaround is to set a flag on SaveStart. I am setting History Status = 1 for now.

Then on SaveEnding, I am checking for HistoryStatus = 1, and sending the confirmation, then setting HistoryStatus back to 0. Unfortunately this then makes the sales order dirty again and it needs to be saved, so it ends up in this loop.

As an alternative, I am setting HistoryStatus = 1 on SaveStart then I am using a 3rd party tool to automatically send order confirmations to customers when a new sales order is created, checking for HistoryStatus = 1. This works well, but the problem I have is that the client also wants confirmation via the 'Emailed' indicator on sales orders that it has been sent. Back in version 6 I would've written to the SO_EmailLog table but in Jiwa 7 it seems it might be easier if I could call the .Net thingos (are they assemblies, or objects, or classes) to advise Jiwa that the email has gone.

I have been looking at this old(ish) post regarding automating Jiwa using Powershell.
viewtopic.php?f=27&t=167 . I think if I could write a Powershell script, passing in as a parameter the InvoiceHistoryID then in theory I think I should be able to set that indicator.

Maybe I am barking up the wrong tree with Powershell, or even using the 3rd party software to send the order confirmation. I either need the plugin to work OK (note that the client is still on 7.0.129) which is preferable because it writes to the email log nicely. Or I need a quick heads up on how to set the email indicator from outside Jiwa. I don't really need the whole email & attachment as binary saved in Jiwa, just that the indicator is set with the email details (To, Subject, staff, datetime etc). I am also a complete & utter newbie on Powershell so I would need to give myself a crash course in it, and I don't have that luxury of time.

What would you suggest?
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Automating Jiwa from command line or script or other

Postby Mike.Sheen » Thu Aug 11, 2016 8:19 pm

Bumping as this has moved to the 2nd page and I still haven't found time to explore a solution.

Hang in there :)

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: Automating Jiwa from command line or script or other

Postby DannyC » Fri Aug 12, 2016 10:09 am

Cool. Nice to know not forgotten!
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Automating Jiwa from command line or script or other  Topic is solved

Postby Mike.Sheen » Wed Nov 09, 2016 3:45 pm

The solution to this is to be strategic about adding and removing handlers.

Attached is a plugin which should do what you want. The key was removing handlers and then re-adding handlers in the right spot.
Attachments
Plugin Sales Order Email New Orders.xml
Sample Plugin
(33.51 KiB) Downloaded 559 times
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 3 guests