Calling code in external DLL through Event VBScript

SOLVED

I am an experienced developer (mostly C#/.NET, some VBScript, Java, C, ...) and have gotten my hands dirty in Sage 500, but not too much. I've been tasked with a bit more customization here.

I would like to call APIs from an external (.NET) DLL via VBScript in the 'Save' Event from the 'Process Receipt of Goods' Activity (Purchase Order section). First off: is this even possible? If so, where can I find the documentation for doing this sort of thing? I guess that's a good first step. Also, if there is sample code, that would be helpful as well. Thanks for any pointers here.

  • 0
    verified answer

    First, it is possible to call COM compliant .NET DLLs from VB script in Sage 500. So the first thing I would verify is that the .NET Assembly you are interested in using can be instantiated and invoke thru COM. If it can't, you will need to create a wrapper Assembly that is COM compliant that can act as a go between vbScript and .NET. A link I have used in the past to help build Com Compliant Assemblies is www.simple-talk.com/.../

    In regards to the task, you should be able to set your code in the Form_Save event of the Customizer script. If this doesn't fulfill the need for your customization and you do not have access to the source code, you can work with any of the Sage 500 ISVs such as E2B or RKL who can assist in building the customization you need.

  • 0 in reply to LouDavis

    Lou, thanks for the response - that page you reference looks very good!

    With regards to the Form_Save event, where can I get documentation about this? E.g. what are the parameters 'oDM' and 'bSave'?

    [Edit] Also, what is the procedure for making the DLL visible to the Sage 500 executable?

  • 0 in reply to cgtyoder
    SUGGESTED
    Are you trying to modify existing Source Code or are you using Sage 500's Customizer capabilities? Sage 500's Help system has information on using Customizer. Also, doing a quick search in Sage City you will see a lot of topics concerning using Customizer as well that might help you.

    In regards to making a DLL visible, if you are doing VB 6 work within the Source code, simply set reference to it and then you can instantiate it using early binding. If you are using VBScript, you can't use early binding so will need to use late binding with CreateObject.. For more information on this refer to this link windowsitpro.com/.../understanding-vbscript-object-management
  • 0 in reply to LouDavis
    I am using the Customizer. I will do some more searching here on this site. Thanks for the link/late binding info!

    One more question -- sorry for the initial barrage! Does there exist source-level debugging for the VBScript scripts? I've done something similar with Visual Studio and Infor CRM (née Sage SalesLogix) - would that work here?
  • 0 in reply to cgtyoder

    There is no way to debug/step through Customizer scripts using 3rd party applications. The Customizer screen you see to create and edit scripts is simply a multi-line textbox. The scripts are saved to the database in 255 character chunks and pulled back together by Sage 500 using code before the scripts are executed or displayed for editing. There is some basic syntax checking capabilities, but other than that not much else.

    There was talk years ago at Sage about redesigning Customizer to give it more capabilities and possibly using VBA instead of vbScript, but nothing came of that.