SDK Code Samples 2018.0

Hey All,

I am looking for code samples to Add inventory, invoices/invoice details.  The SDK is pretty slim on code examples for this.  Anyone willing to share?

TIA,

Miles

[email protected]

  • 0

    Hi,

    I thought there were examples of how to do all those things in the C# example file.  Uncomment the part of the code you want to run in 'main'.

    The C++ and VBA examples are pretty sparse.

  • 0 in reply to RandyW

    very sketchy.  The SDKInstanceManager code samples don't work when the Connection Manager is started.  And it always return false when opening the database.  This would be ideal if it actually worked.

    When the connection manager is started, then all of the sample calls using Sage_SA_dblyr.dll do work.  But there are no function calls referenced for Adding, Updating or Deleting records.  So this solution is a dead end without that information.

  • 0 in reply to Miles Gibson

    Miles Gibson said:
    But there are no function calls referenced for Adding, Updating or Deleting records.  So this solution is a dead end without that information.

    Instead of using function calls into a DLL, use the API calls in the C# example

    In SDKExample.cs  from the 2018.1 SDK:

    AddLedgersExample starts at line 235

    The inventory item creation is from Line 362 to 379

    ProcessInvoicesExample starts at line 1082

    The Pay Later purchase example starts at line 1099

    Reversing a posted invoice example starts at Line 1288

    Miles Gibson said:
    The SDKInstanceManager code samples don't work when the Connection Manager is started.  And it always return false when opening the database.

    The c# example won't work if the database is currently open, in Single User Mode.  (Single User Mode is the only mode possible until multiple users are configured)

    Try the precompiled SDKExample.exe in the c# folder.  Get the example working, and save a copy of the entire folder so that you can go back to it and test whether it's a problem in code you're added / modified, or in the compiler, or just the username / password being rejected.

    The precompiled example is set with the AddLedgersExample uncommented.   You should be able to run it against the provided sample data file with the user name 'sysadmin' (all lower case) and no password (hit enter)

    Once that's working, try uncommenting some of the other examples in main, and recompile and run.  This is what I got:

    C:\work\Programs\SDK\SA2018.1WorkingCopy\Sample\c#>sdkexample.exe
    Enter file name of a sample Sage 50 data
    > C:\Users\Public\Documents\Simply Accounting\2018\Samdata\Enterprise\Universl.SAI

    Enter username
    > sysadmin

    Enter password
    >

    Opening database...


    -----------------------------------
    Adding Ledger Records Example
    -----------------------------------

    Enter a new Account Number:  1234
    The value you are attempting to set for this field is invalid.

    Enter a new Vendor name:  Miles Gibson
    Vendor added successfully

    Enter a new Customer name:  Gibson, Miles
    Customer added successfully

    Enter a new Employee name:  Gibson, Miles Davis
    Employee added successfully

    Enter a new Inventory number:  AMB ulance12345
    Inventory added successfully

    Enter a new Project name:  Software
    Project added successfully

    C:\work\Programs\SDK\SA2018.1WorkingCopy\Sample\c#>

  • 0 in reply to RandyW

    I got it working.  Re-installed the 2018.0/.1 SDKs.  Walked through the C# console application. So most of it works, although not all of the commented out demo calls work, depending on your Sage company configuration.  

  • 0 in reply to Miles Gibson

    Miles Gibson said:
    I got it working.

    The SDK could really use a 'Getting Started' guide, if I worked for Sage I would probably write one.  I may do that anyway, although any potential audience is leaving the Windows Desktop... in groups.

    Paid support is available from Sage, as far as I know it's the same SDK with access to a support line. 

    Miles Gibson said:
    Walked through the C# console application.

    I suggested that first, because it's where all the useful stuff is.  The C++ and VB samples are 'proof of concept' that you can open a Sage 50 data file and read data.

    Miles Gibson said:
    although not all of the commented out demo calls work, depending on your Sage company configuration.

    The possible permutations and configurations are almost endless, probably they wanted to produce a really basic sample. 

    Additional code that would manage length of account numbers, chart of account groupings, linked accounts, currencies enabled, departments, projects, primary language preference, year ends, prior fiscal periods, etc. could be so complex as to be more confusing than illustrative.

    See dev-dotnetref.chm for a more complete list of API calls.  It is *not* the same information as dev-dotnetref.pdf