Tuesday, April 23, 2019

Creating transactions with gift certificates through scripting results to Invalid authcode reference key xx for currency xx

Since the authcode is a list of gift certificate (GC), you may think that this an integer when passed to the Gift Redemption sublist. Instead, this is considered as a string. Thus, when you indicate the gift certificate internal ID, ensure that you put quotes to make it as a string.

This sample code creates a sales order with a gift certificate attached:

var rec = nlapiCreateRecord('salesorder');
rec.setFieldValue('entity', 8);
rec.setCurrentLineItemValue('item', 'item', 14);
rec.setCurrentLineItemValue('item', 'quantity', '1');
rec.setCurrentLineItemValue('giftcertredemption', 'authcode', '4'); // the GC Internal ID as string

No comments:

Post a Comment