I'm new to Sage and I've been working on a sample app using DispatchObject. The goal will be to eventually pull and push data GL entries. I changed the sample to return AddressLine1, however; the sample only returns the customer number. // Instantiate a ProvidexX.Script object and initialize with the path to MAS90\Home using (DispatchObject pvx = new DispatchObject("ProvideX.Script")) { pvx.InvokeMethod("Init", masHomePath); // Instantiate a new Session object and initialize the session by setting the user, company, date and module using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session"))) { oSS.InvokeMethod("nLogon"); oSS.InvokeMethod("nSetCompany", company); oSS.InvokeMethod("nSetUser", userName, password); oSS.InvokeMethod("nSetDate", "A/R", DateTime.Now.ToString("yyyyMMdd")); oSS.InvokeMethod("nSetModule", "A/R"); // Get the Task ID for the AR_Customer_ui program int TaskID = (int)oSS.InvokeMethod("nLookupTask", "AR_Customer_ui"); oSS.InvokeMethod("nSetProgram", TaskID); using (DispatchObject dispatchObject = new DispatchObject(pvx.InvokeMethod("NewObject", "AR_Customer_svc", oSS.GetObject()))) { String columns = "CustomerName$"; String keys = "CustomerNo$"; String returnFields = "AddressLine1$"; String returnAccountKeys = "AddressLine1$"; String whereClause = "CustomerName$=" + Convert.ToChar(34) + "Customer 1" + Convert.ToChar(34); // Setup the parameter list to be passed as reference to the GetResultSets method object[] getResultSetParams = new object[] { columns, keys, returnFields, returnAccountKeys, whereClause, "", "" }; // Call the GetResultSets to return the list of Customer numbers and names dispatchObject.InvokeMethodByRef("nGetResultSets", getResultSetParams); // The ProvideX SEP character is referenced by character number 352 within C# // Split the customer names into string array and list them in a console window string[] names = getResultSetParams[2].ToString().Split(System.Convert.ToChar(352)); for (int x = 1; x names.Length - 1; x++) System.Console.WriteLine("Name " + x.ToString() + ": " + names[x]); } }
↧