Sage API Importing Question

SUGGESTED

Hello everyone. I have a question about the Sage 50 SDK. I am trying to create a PO in Sage through the API. Using .Net and C#, I can see the Lines and the specific fields for the PO itself, but I am unsure how to set the Vendor the PO is linked to in the code. I see the PO has VendorReference for the field I need to use, but I can't figure out how to set an Entity Reference. I have never coded in .Net or C# before now, and it has been 20 years since I did anything with my C++ programming before this. I don't remember anything about Entity References and how to work with them, so if anyone can point me to something that would Instruct me on how to do what I need, I would greatly appreciate it. We have the 2018 version of the SDK.

I am going to be pulling the information from a CSV file that is exported from a different database, and I just want to pull the information from the CSV file and import the data into Sage without needing to go through the manual process in Sage itself. I have this button that can pull out the data, put it into a CSV file and call the .exe file to run the code for the API and spit out whatever errors I get or anything else. That part is working, it is just the API part itself that I can't figure out. 

I have the following items.

PurchaseOrder PO_New = company.Factories.PurchaseOrderFactory.Create();
PurchaseOrderLine LineItem = PO_New.AddLine();

Then I have the different fields that I want to import being set to the specific fields, but I can't get the VendorReference to actual be set to anything. I know the PO_New.VendorReference.Equals just compares the two to see if they are equal to each other. Is there anything that I can use to set the VendorReference field to be equal to something from the Vendor table that contains a VendorID string or something else? I can't find anything in the supplied Sample Codes that does ANYTHING with POs or importing into the PO table at all.

Any help would be greatly appreciated, even just hey read up on this here to figure it out.

Thanks

  • 0
    SUGGESTED

    Set the VendorReference using the Key property of the Vendor you want to use. You can find the vendors in the company.Factories.VendorFactory.List(). 

    once you have an appropriate vendor, you assign the Key property:

    PO_New.VendorReference = vendor.Key;

    And that pattern is pretty much true of any <something>Reference property in the SDK.