Values Not Stored in Custom Transaction Body Fields

In some Elbrus implementations of SuiteCommerce Advanced (SCA), text entered into custom transaction body fields during the checkout flow do not display in the Custom subtab of the resulting sales order as expected. These patch instructions describe how to correct this problem.

To implement this patch, create a custom module to override the CustomFields.js file, which is part of the CustomFields module. If you are not familiar with implementing patches for SCA, refer to the following:

Step 1: Create the Override File

Following the instructions and recommendations in the Patch Using Override Mode procedure, create a new directory and file: /Modules/extensions/CustomFieldsExtension@1.0.0/JavaScript/CustomFields.js.

In the new CustomFields.js file, find and replace the following lines with the provided code sample.

Find these lines:

            WizardStep.prototype.afterModuleInstanceCreated.install({
            name: 'custom-fields-wizard-step-module-instance-created'
   ,          execute: function(moduleInstance)
            {
               
               //Add the model of the wizard to the context of all the modules to support transaction body fields
               var originalGetContextFunction = moduleInstance.getContext;               
               moduleInstance.getContext = function()
               {   
                  var context = originalGetContextFunction.apply(moduleInstance, arguments);
                  if(!context.model)
                  {
                     context.model = moduleInstance.model;
                  }
                  return context;                     
               };               
               moduleInstance.events = moduleInstance.events || {};               
               _.each(moduleInstance.model.get('options'), function(optionValue, optionKey)
               {                  
                  moduleInstance.events['change [name="' + optionKey + '"]'] = updateOption;
               });
            }
         }); 

          

And replace them with the following code:

            WizardStep.prototype.afterModuleInstanceCreated.install({
            name: 'custom-fields-wizard-step-module-instance-created'
   ,          execute: function(moduleInstance)
            {
               
               //Add the model of the wizard to the context of all the modules to support transaction body fields
               var originalGetContextFunction = moduleInstance.getContext;               
               moduleInstance.getContext = function()
               {   
                  var context = originalGetContextFunction.apply(moduleInstance, arguments);
                  if(!context.model)
                  {
                     context.model = moduleInstance.model;
                  }
               moduleInstance.events = moduleInstance.events || {};               
               _.each(context.model.get('options'), function(optionValue, optionKey)
               {                  
                  moduleInstance.events['change [name="' + optionKey + '"]'] = updateOption;
               });
                  return context;
               };
            }
         }); 

          

Step 2: Prepare the Developer Tools For Your Patch

When preparing the Developer Tools for your patch as described in the Patch Using Override Mode procedure, you should:

  1. Paste the following sample code into the new ns.package.json file that you create in the Modules directory: /Modules/extensions/CustomFieldsExtension@1.0.0/ns.package.json

                    {
       "gulp": {
          "javascript": [
             "JavaScript/*.js"
          ]
       },
       "overrides": {
          "suitecommerce/CustomFields@X.Y.Z/JavaScript/CustomFields.js" : "JavaScript/CustomFields.js"
       }
    } 
    
                  
    Important:

    In the preceding code sample, you must replace the string X.Y.Z with the version of the module in your implementation of SuiteCommerce Advanced.

  2. Open the distro.json file and then add your custom module to the modules object as described in the Patch Using Override Mode procedure. The following sample shows the value to add to the list of existing values that follow the “modules” key.

                    "modules": {
        "extensions/CustomFieldsExtension": "1.0.0",
        . . . 
    
                  

Step 3: Test and Deploy Your Patch

Follow the instructions provided in the Patch Using Override Mode procedure to test and deploy your patch.

Related Topics

SCA Patches

General Notices