Friday, July 12, 2019

Avoid getting "Invalid salesorder reference key <salesorder id> for customer <customer id>" when adding Customer Deposit via Web Services.

Submitting a customer deposit via Web Services however it throws an error "Invalid salesorder reference key <salesorder id> for customer <customer id>".

Sample Scenario:
1. Sales Order with internal id 35499 is already billed.
2. Create Customer Deposit by invoking the following web services request:
 <soap:Body>
    <platformMsgs:add>
      <platformMsgs:record xsi:type="tranCust:CustomerDeposit">
        <tranCust:customer internalId="16128"/>
        <tranCust:salesOrder internalId="35499"/>
        <tranCust:payment>100</tranCust:payment>
      </platformMsgs:record>
    </platformMsgs:add>
  </soap:Body>

Actual Result:
 <soapenv:Body>
    <addResponse xmlns="urn:messages_2012_1.platform.webservices.netsuite.com">
      <writeResponse>
        <platformCore:status isSuccess="false" xmlns:platformCore="urn:core_2012_1.platform.webservices.netsuite.com">
          <platformCore:statusDetail type="ERROR">
            <platformCore:code>INVALID_KEY_OR_REF</platformCore:code>
            <platformCore:message>Invalid salesorder reference key 35499 for customer 16128.</platformCore:message>
          </platformCore:statusDetail>
        </platformCore:status>
      </writeResponse>
    </addResponse>
  </soapenv:Body>
Expected Result: Customer Deposit should be created successfully.
When checking the sales order  35499 (this is just a sample order) and it shows that this order is already billed so when I try to create deposit for this order then it  will throw invalid reference key error.  If you check in the UI, "Create Deposit" is also not showing up in the form.

This is also related to SuiteAnswers 21653 which states the following:

If the Create Deposit Button is not visible on the Sales Order Record, the reason must be one of the following:
 
1.   The status of the Sales Order is Cancelled, Closed or Billed.
2.   The Sales Order Form is of the Standard Sales Order Type and the Payment Method field is not blank.
3.   The Sales Order Form is of the Cash Sale Type.
4.   The Sales Order Form is customized to not show the Create Deposit Button.
 

 

1 comment: