ValidationException when building CustomerCreditMemo - Sage 50 SDK .NET

SOLVED

Greetings all,

We use the .NET SDK for Sage 50 to integrate our software with Sage 50.

I've got a situation where we're trying to make a Credit Memo in our software to push over in to sage 50. During a relatively routine step, we are getting a Sage ValidationException message. This code has worked fine in the past, but our users don't make too many Credit Memos (so it's possibly been years since they last attempted to work with Credit Memos) and I suspect there's something different going on in Sage 50 2019, possibly?

Here's a small C# code snippet:

// Time to get down to business. Let's create our Credit Memo and start filling that object up.
Sage.Peachtree.API.CustomerCreditMemo PeachCreditMemo = myPTCompany.Factories.CustomerCreditMemoFactory.Create();

PeachCreditMemo.CustomerPurchaseOrderNumber = GeneratePOString(RealtracInvoice);
log.WriteLog("PeachCreditMemo.CustomerPurchaseOrderNumber: " + PeachCreditMemo.CustomerPurchaseOrderNumber);

log.WriteLog("** About to assign PeachCreditMemo.CustomerReference");
log.WriteLog("AddCreditMemo() - Adding Customer Key: " + PeachCustomer.Key.ToString());
PeachCreditMemo.CustomerReference = ((Sage.Peachtree.API.Customer)PeachCustomer).Key;
log.WriteLog("**** DONE with assignment PeachCreditMemo.CustomerReference");

When I assigned the Peach Customers' Key to the CustomerReference, Sage throws a Validation Exception... here's the debug output right at that moment:

08:27:11     1368     08:27:11: PeachCreditMemo.CustomerPurchaseOrderNumber: 478109
08:27:11     1368     08:27:11: ** About to assign PeachCreditMemo.CustomerReference
08:27:11     1368     08:27:11: AddCreditMemo() - Adding Customer Key: EntityReference<Customer>:6a1eda1e-9fbc-4131-b76d-e1151ba625fe
08:27:11     1368     Considering Assembly at path:C:\PROGRA~2\Sage\PEACHT~1\Sage.SBD.ACS.Framework.DataTypes.dll
08:27:11     1368     Sage.Peachtree.API.Resolver - Assembly FullName values match exactly.  Assembly accepted.
08:27:11     1368     08:27:11: Sage error validating credit memo (#79151) . Specific errors listed below.
08:27:11     1368     08:27:11: Property:  Message: Unknown validation problem.
08:27:11     1368     08:27:11: Error exporting credit memo NID: 79151. Fatal error.

So I can assign the Purchase Order number fine to my CustomerCreditMemo object. But when I go to assign my Sage Customer to the CustomerCreditMemo, Sage loads Sage.SBD.ACS.Framework.DataTypes.dll, and then immediately throws the ValidationException.

I know my customer is legitimate. I have pretty much the exact same code for creating Sage SalesInvoice objects, and they work perfect for this same Peach Customer. I compared the keys and Peachtree/Sage Customer objects and they are the same, but for whatever reason when I do:

PeachCreditMemo.CustomerReference = ((Sage.Peachtree.API.Customer)PeachCustomer).Key;

I get an exception; if I do

PeachInvoice.CustomerReference = ((Sage.Peachtree.API.Customer)PeachCustomer).Key;

using the same Sage/Peachtree Customer it works fine.

  • +1
    verified answer

    And 5 hours later, I've found a fix. Don't know why this is a fix, but it did allow the credit memo to Post.

    In Sage, the Customer was set up with a Customer ID like "ABCD/S" and their Company Name was "ABCD COMPANY MILFORD - NORTH AMERICA".

    If I went in to their Sage customer record, and changed their name from "ABCD COMPANY MILFORD - NORTH AMERICA" to just "ABCD COMPANY MILFORD" the Credit Memo would post fine.

    If the company name as it was originally, I could post Invoices to that company just fine. But as soon as I tried assigning that company to the Credit Memo, Sage would throw the ValidationException mentioned above.

    Long story short, if you see a ValidationException message when assigning a Company to a Sage 50 CustomerCreditMemo object, try tweaking/changing the name of the company in the Sage 50 Customer Center record.

    Weird.