AccpacCOMAPI

SUGGESTED

Hi there,

I have a client on Sage 300 5.6 and have upgraded them to 2020. There was some legacy code written to connect an external program through the AccpacCOMAPI but it is now broken. Specifically, when I try to run this, it fails when trying to open and says 'Invalid Signon Information. Make sure you supply the correct User ID and Password.' The username, password and database are definitely still correct.

I feel like this is the code that broke:

var Accpac = new ActiveXObject("ACCPAC.Session");
if (ServerName.substr(0,6).toLowerCase() == 'net://')
{
    Accpac.RemoteConnect (ServerName, UserId, UserPassword, "");
}
Accpac.Init ("", "EW", "EW9999", "56A");
Accpac.Open(UserId, UserPassword, Database, now.getVarDate(), 1, "");
Has this connection been depricated? If not, is there something that jumps out to any of you that may indicate what broke here and how to fix it?
EDIT: relevant conditional statement added to the code
Parents
  • 0

    Is the UserID and Password in upper case?

    Maybe try early binding on the Session object. Also confirm that there is only one reference to the Sage/runtime in Environment Variables.

  • 0 in reply to SergeB

    I ensured the userid and password were both uppercase. I also checked and there is only one reference to the sage\runtime in the environment variables.

    I did, however notice this piece of code: 

    if (ServerName.substr(0,6).toLowerCase() == 'net://')
    {
        Accpac.RemoteConnect (ServerName, UserId, UserPassword, "");
    }

    So it actually looks like this: 

    var Accpac = new ActiveXObject("ACCPAC.Session");
    if (ServerName.substr(0,6).toLowerCase() == 'net://')
    {
        Accpac.RemoteConnect (ServerName, UserId, UserPassword, "");
    }
    Accpac.Init ("", "EW", "EW9999", "56A");
    Accpac.Open(UserId, UserPassword, Database, now.getVarDate(), 1, "");

    I believe this means that the connection is done with the now discontinued web deployment.

    Does this give you another idea for what may fix it?

  • 0 in reply to Gabriel Faulhaber

    Because your calling new ActiveXObject, I'm guessing that's javascript right?

    Your probably going to have to hit the new REST api for that to work. If the webscreens have been installed, the REST api is at {hostname}/sage300webapi

  • 0 in reply to SergeB

    It's almost javascript. Microsoft added the ActiveXObject in Jscript, their flavour of javascript.

    The integration is rather large and I was hoping to not have to rebuilt it from the ground up, but if that's the only way forward then I'll have to do it.

    I think the REST API won't work for me because among other things, I need post capabilities for OE invoices and put/patch capabilities for OE orders. I believe that's not possible to do with the REST API.

    If I have to go through the work of rewriting the integration, I'll need to get a better understanding of Sage 300's current APIs and the capabilities of each. It might be for another post, but if you have something in mind, that would be great.

  • 0 in reply to Gabriel Faulhaber

    Without seeing your code take the following with a grain of salt. You could write your own web service or web API and deploy that on the Sage 300 server. Client side, create a wrapper for your accpac object that calls your service.

    Have you checked the http payload thats being sent to the server to ensure that the username and pass is correct?

  • 0 in reply to Gabriel Faulhaber

    Hi Gabriel, if you'd like to take a look at our EnableTRANS framework, it provides for the import via a service and/or Sage UI. Cheers, Derek Kellock, Enablecore

Reply Children
No Data