Hi Everyone, Need help, working on an extension wh...
# suitecommerce
s
Hi Everyone, Need help, working on an extension which sets a custom transaction body field using Cart.setTransactionBodyField() when the standard Checkout -> "Select Shipping Address" page loads. This totally works fine for the first order placed after login (my custom transaction field in NS gets populated) but for the second consecutive order the custom field does not get populated (all the console.logs are working as they should but field is not getting populated). Any idea why the extension is behaving like this? How can I resolve this? Here is my code:
mountToApp: function mountToApp(container) {
   
var Checkout = container.getComponent('Checkout');
   
Checkout.on('afterShowContent', function () {
       
Checkout.getCurrentStep().then(function (step) {
           
if (step && step.step_group_name == "Shipping Address") {
               
var Cart = container.getComponent('Cart');
               
var fieldObj = {
                   
fieldId: "custbody_my_custom_field",
                   
value: "Hello World!",
                   
type: "string",
               
};
*Cart.setTransactionBodyField(fieldObj)*.then(function () {
                   
console.log(fieldObj.fieldId + ' was set to ' + fieldObj.value);
                   
var liveOrderObj = LiveOrderModel.getInstance();
                   
console.log("liveOrderObj", liveOrderObj);
               
}).fail(function (error) {
                   
console.log('setTransactionBodyField failed.', error);
               
});
           
}
       
}
   
}
}