- Problem: The location field at the line level is not being populated when a quote is converted to a sales order using the credit card payment method via the webstore. However, the location is correctly set when using invoice payments.
- Inconsistent behavior in sales order creation, leading to incomplete or incorrect location data based on the payment method used.
Root Cause Analysis
- Default System Behavior: The standard forms for Quotes and Sales Orders do not include a line-level location field. The system does not inherently support setting this field during the conversion process.
- Payment Method Behavior:
- When using invoice payments, the system assigns a custom form that includes the location field, and the conversion works correctly.
- For credit card payments, the system does not assign any custom form, which results in the use of the default form without a line-level location field.
Solution
Code Review & Updates:
- Investigate the existing transformation logic that converts a quote to a sales order, particularly focusing on form assignment based on the payment method.
- Identify that invoice payment transactions were using a custom form, but credit card payments were not.
Method Update:
- Updated the
getTransactionRecordmethod inQuoteToSalesOrderModelto handle custom form selection for both payment types (invoice and credit card). - Ensure that the
nlapiTransformRecordfunction includes the custom form ID for credit card payments using the methodgetInvoiceCustomFormId().
getTransactionRecord: function () { if (this.salesorderId && this.salesorderId !== 'null' && this.salesorderId !== 'undefined') { return nlapiLoadRecord('salesorder', this.salesorderId); } var payment_method_list = this.data ? this.data.paymentmethods : []; var invoice_payment_method = _.findWhere(payment_method_list, { primary: true, type: 'invoice' }); return nlapiTransformRecord('estimate', this.quoteId, 'salesorder', { recordmode: 'dynamic', customform: this.getInvoiceCustomFormId() // Ensure custom form is applied }); },
- Updated the extension “AddNoteInQuote” and Extended the
'QuoteToSalesOrder.Modelmodel in the suitescript file to make above changes in thegetTransactionRecordmethod and assigned the customer from in the conversion of the quote to sales order for both having payment as invoice and credit card - I confirmed that after applying the custom form for credit card payments, the line-level location was correctly populated.