I'm getting closer but I'm still not there: I'm trying to create a Customer record in MAS using BOI. I'm using C#, so I have to use late binding. When I call "nWrite" I get the following error (sLastErrorMsg):
"CA SAC" is not numeric.
First off, I'm not even specifying a Tax Schedule but I think It's grabbing it from the Zip Code. Second, Tax Schedule doesn't have a numeric field... It's just the Tax Abbrev and the description. Even if I specify the TaxSchedule$ I get the same error. This is my code:
using (DispatchObject oARCustomerEntry = new DispatchObject(pvx.InvokeMethod("NewObject", "AR_Customer_bus", oSS.GetObject())))
{
try
{
object[] nextCustomerNumber = new object[] { "CustomerNo$" };
//Getting Next Customer Number
oARCustomerEntry.InvokeMethodByRef("nGetNextCustomerNo", nextCustomerNumber);
Console.WriteLine(nextCustomerNumber[0].ToString());
object retVal = 0;
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "ARDivisionNo$", "60" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "CustomerNo$", nextCustomerNumber[0].ToString() });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKey", new object[] { "" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CustomerName$", "JOHN SMITH JR" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine1$", "1234 LONG DREAM ST" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine2$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine3$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "City$", "CITRUS HEIGHTS" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "State$", "CA" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "ZipCode$", "95621" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CountryCode$", "USA" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalespersonDivisionNo$", "60" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nWrite", new object[] { "" });
string customerNumber = nextCustomerNumber[0].ToString();
Console.WriteLine(retVal.ToString());
Console.Read();
}
catch (Exception ex)
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Console.WriteLine(errorMsg.ToString());
Console.WriteLine(ex.Message);
Console.Read();
}
finally
{
oARCustomerObject.Dispose();
}
}
The console is displaying the Next Number then 2 and 1 and 1 and it breaks when I called nWrite.
Any ideas... I know the code is really ugly but since I'm working with C# I have to use late binding.
Thanks