CMS Page Type Website Records Not Displaying (SCA 2022.1 – 2023.2)

Before you get started, familiarize yourself with Best Practices for Customizing SCA.

Step 1: Update the CMS.json File

  1. Open the following file: Advanced/CMSadapter/Configuration/CMS.json

  2. Find and delete the following code:

                    },
     "cms.lazySettingsLoad": {
     "group": "integrations",
     "subtab": "cms",
     "title": "CMS Pages Lazy Load",
     "description": "Enter the Custom Script Record IDs for the settings of the CMS pages you do not want to load
    into the shopping environment short cache.",
     "type": "array",
     "items": {
     "type": "string",
     "title": "Custom Record Script Id"
     },
     "default": [] 
    
                  
  3. Save the file.

Step 2: Update the CMSadapter.Model.v3.js File

  1. Open the following file: Advanced/CMSadapter/SuiteScript/CMSadapter.Model.v3.js

  2. Find the following code:

                    'Utils',
     'Configuration'
    ], function(SCModel, SiteSettingsModel, _, Utils, Configuration) { 
    
                  
  3. Replace it with the following code:

                    'Utils'
    ], function(SCModel, SiteSettingsModel, _, Utils) { 
    
                  
  4. In the same file, find and delete the following code:

                    const lazySettingsLoad = _.map(
     Configuration.get('cms.lazySettingsLoad', []),
     scriptId => scriptId.toUpperCase()
     );
     _.each(settingsRecords, function(ids, recname) {
     if (lazySettingsLoad.indexOf(recname.toUpperCase()) === -1) {
     const cr = nlapiCreateRecord(recname);
     const crFilters = [
     new nlobjSearchFilter('internalid', null, 'anyof', _.keys(ids))
     ];
     const crColumnsRaw = cr.getAllFields().filter(function(fieldname) {
     return fieldname.indexOf('custrecord') === 0;
     });
     const crColumns = crColumnsRaw.map(function(column) {
     return new nlobjSearchColumn(column);
     });
     const settings = nlapiSearchRecord(recname, null, crFilters, crColumns);
     settings.forEach(function(setting) {
     const { id } = setting;
     settingsRecords[recname][id].fields = {};
     _.each(crColumnsRaw, function(columnName) {
     settingsRecords[recname][id].fields[
     columnName
     ] = setting.getValue(columnName);
     });
     });
     }
     }); 
    
                  
  5. Save the file.

Step 3: Update the PageTypeSettings.Handler.ts File

  1. Open the following file: Backend/Common/PageType/PageTypeSettings.Handler.ts

  2. Find the following code:

                    recSearch.run().each(function(data) {
     util.each(columns, function(column) {
     result[column] = data.getValue(column);
     });
     return true;
     });
     return result;
     }
    } 
    
                  
  3. In the line between the last two curly brackets, insert the following code:

                    public isCustomRecordValid(recordType: string) {
     const recSearch = search
     .create({
     type: 'cmspagetype',
     filters: ['customrecordscriptid', 'is', recordType],
     columns: ['customrecordscriptid']
     })
     .run();
     return recSearch.getRange({
     start: 0,
     end: 1
     }).length;
     } 
    
                  

    The updated code should look like this:

                    recSearch.run().each(function(data) {
     util.each(columns, function(column) {
     result[column] = data.getValue(column);
     });
     return true;
     });
     return result;
     }
    public isCustomRecordValid(recordType: string) {
     const recSearch = search
     .create({
     type: 'cmspagetype',
     filters: ['customrecordscriptid', 'is', recordType],
     columns: ['customrecordscriptid']
     })
     .run();
     return recSearch.getRange({
     start: 0,
     end: 1
     }).length;
     }
    } 
    
                  
  4. Save the file.

Step 4: Update the PageTypeSettings.ServiceController.ts File

  1. Open the following file: Backend/Common/PageType/PageTypeSettings.ServiceController.ts

  2. Find the following code:

                    import { notFoundError } from '../../Common/Controller/RequestErrors'; 
    
                  
  3. Replace it with the following code:

                    import { notFoundError, forbiddenError } from '../../Common/Controller/RequestErrors'; 
    
                  
  4. In the same file, find the following code:

                    ): HttpResponse<PageTypeSettings> {
     const record: PageTypeSettings = this.PageTypeSettingsHandler.get(id, params); 
    
                  
  5. Between the two lines of code, insert the following code:

                    if (!this.PageTypeSettingsHandler.isCustomRecordValid(params.recname)) {
     throw forbiddenError;
     } 
    
                  

    The updated code should look like this:

                    ): HttpResponse<PageTypeSettings> {
     if (!this.PageTypeSettingsHandler.isCustomRecordValid(params.recname)) {
     throw forbiddenError;
     }
     const record: PageTypeSettings = this.PageTypeSettingsHandler.get(id, params); 
    
                  
  6. Save the file.

Step 5: Update the PageType.Component.ts File

  1. Open the following file: Commons/PageType/JavaScript/PageType.Component.ts

  2. Find the following code:

                    const lazySettingsLoad = _.map(
     Configuration.get('cms.lazySettingsLoad', []),
     (scriptId: string) => scriptId.toUpperCase()
     );
     if (
     page.get('customrecordscriptid') &&
     lazySettingsLoad.indexOf(
     page.get('customrecordscriptid').toUpperCase()
     ) !== -1
     ) { 
    
                  
  3. Replace it with the following code:

                    if (page.get('customrecordscriptid')) { 
    
                  
  4. Save the file.

Step 6: Set Permissions for PageTypeSettings.ss

  1. In NetSuite, go to Documents > Files > File Cabinet.

  2. Go to the following location: Web Site Hosting Files > Live Hosting Files > SSP Applications > NetSuite Inc. -X.Y.Z > Development2 > services

    Important:

    You must replace the string, X.Y.Z, with the version of SCA you are using.

  3. Click Edit next to the file, PageTypeSettings.ss.

  4. Go to the Permission tab and check the Enabled box.

  5. From the Execute as Role list, select Store Manager.

  6. Check the Run Script Without Login box.

  7. Click Save.

Related Topics

General Notices