Note: The programming language for scripts in Smart Office is JScript.NET.

Installation

Follow these steps to run the script above:

Download and install Skype on the computer that is running Smart Office (the script must communicate with Skype locally). Then sign in to Skype (the script will not work if you are not signed in). Also, your Skype account must have credit (USD, EUR, etc.) to be able to send SMS.

Download and unzip Skype4COMsomewhere in your computer, for example C:\Program Files\Skype\skype4com-1.0.36\ . Skype4COM is the API used to send/receive Skype commands. Then register the DLL Skype4COM.dll with the following command:

regsvr32 Skype4COM.dll

Download and install SEHE and place the file Interop.SKYPE4COMLib.dll somewhere in your computer or somewhere on the network so that it is accessible by the Smart Office computer, for example C:\Program Files\Skype\SEHE\Interop.SKYPE4COMLib.dll or http://host/path/Interop.SKYPE4COMLib.dll . That DLL contains the Interop code to be able to call Skype4COM from the .NET framework.

Launch Smart Office, and log in.

For the Script Tool it is necessary to have an M3 program open, so open for example Customer. Open – CRS610.

Open the Script Tool with the following command:

mforms://jscript

Copy/paste the sample script above into the Script Tool

Change the path to the DLL. In my example I used C:\\Program Files\\Skype\\SEHE\\Interop.SKYPE4COMLib.dll . Make sure to escape the backslashes in the String with double backslashes.

Can we use this assembly all the time ? Trying to use a .dll (PdfSharp.dll stored in a folder under C:/) to test the merge feature on .pdf files. The script compiles well but miserably crashes during execution.

Hello Maxime. Yes, that post is five years old, and about a year after it, the solution didn’t work anymore; I don’t remember if because Skype had changed something, or because Smart Office had changed something. Anyway, it should still be possible to load assemblies. Try with another assembly. For example, try one of the Smart Office assemblies, it should say “already loaded” or something. Or try with one of the Smart Office applications not yet loaded, like the Process Automation Inbasket that I think doesn’t get loaded if the ProcessFlow checkbox is unchecked in the Profile Editor; that shouldn’t throw an error. Proceed like that until you find what’s happening with your DLL. I see you’re trying to use the PdfSharp DLL. If you get it to work, come write about it on the blog, it will certainly help others. Also, check out Karin’s post on printing from Smart Office; I don’t remember the link. I think there’s some View As Pdf now in Smart Office, so there may already be an assembly available. Hope it helps.

I tried another approach. Was able to create a MEC mapping that :
1) retrieves the .pdf files in IDM (Infor Document Managment) through a query (using IDM API provided by Infor). You can XQuery the database and retrieve for example delivery note + invoice + whatever document for a given DLIX number

2) Merge the .pdf files into one by using PDFBox-app.2.0.2.jar
– that’s so cool !

Next step :
– create a widget in SmartOffice to trigger the mapping. The user will choose which documents to retrieve (checkboxes) and will enter the DLIX number as filtering criteria. The OnClick event will create an XML file in MEC /input directory
– run mapping and send the merged.pdf file into user’s mailbox

Greetings. Just posted a short demo on yt. Tell me what you think about it. Main drawback at the moment is that we generate 1 CMR document in IDM each time the user launch a “print” command in M3 (from MWS260). We have duplicates. There is no “flag copy” on the CMR doc in standard; maybe will do a bit of MAK on MWS610 header to force the user to check the CMR as “final version” in order to write one copy only in IDM. Maybe you have an idea on this one ? I am sure we can select the last record through IDM API query but my poor java skills do not allow me to go deeper into the code.

Thank you ! CMR (lettre de voiture) is a document for the forwarding agent : we use it for customs. The combined .pdf is send by email to the user so he can check what is inside before forwarding by email to the forwarding agent’s mailbox.
I will write a word document to present the solution + code and send it to you.

Maxime, I just read your draft, and it looks good. Please write your name at the bottom of your post so people can tell us apart (even though it’s already in the author further below). I would explain why you chose MEC (I think because you couldn’t find how to load a .NET assembly at runtime), because otherwise it doesn’t make sense to me to use MEC for a client-side operation that can be done in .NET. I would also show a screenshot of the result (email with attachment). Then click Publish 🙂