Step 1: Update the CMS.json File
- Open the following file: Advanced/CMSadapter/Configuration/CMS.json
- 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": []
- Copy
- Save the file.
Step 2: Update the CMSadapter.Model.v3.js File
- Open the following file: Advanced/CMSadapter/SuiteScript/CMSadapter.Model.v3.js
- Find the following code:
'Utils',
'Configuration'
], function(SCModel, SiteSettingsModel, _, Utils, Configuration) {
- Copy
- Replace it with the following code:
'Utils'
], function(SCModel, SiteSettingsModel, _, Utils) {
- Copy
- 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);
});
});
}
});
- Copy
- Save the file.
Step 3: Update the PageTypeSettings.Handler.ts File
- Open the following file: Backend/Common/PageType/PageTypeSettings.Handler.ts
- Find the following code:
recSearch.run().each(function(data) {
util.each(columns, function(column) {
result[column] = data.getValue(column);
});
return true;
});
return result;
}
}
- Copy
- 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;
}
- Copy
- 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;
}
}
- Copy
- Save the file.
Step 4: Update the PageTypeSettings.ServiceController.ts File
- Open the following file: Backend/Common/PageType/PageTypeSettings.ServiceController.ts
- Find the following code:
import { notFoundError } from '../../Common/Controller/RequestErrors';
- Copy
- Replace it with the following code:
import { notFoundError, forbiddenError } from '../../Common/Controller/RequestErrors';
- Copy
- In the same file, find the following code:
): HttpResponse<PageTypeSettings> {
const record: PageTypeSettings = this.PageTypeSettingsHandler.get(id, params);
- Copy
- Between the two lines of code, insert the following code:
if (!this.PageTypeSettingsHandler.isCustomRecordValid(params.recname)) {
throw forbiddenError;
}
- Copy
- 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);
- Copy
- Save the file.
Step 5: Update the PageType.Component.ts File
- Open the following file: Commons/PageType/JavaScript/PageType.Component.ts
- 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
) {
- Copy
- Replace it with the following code:
if (page.get('customrecordscriptid')) {
- Copy
- Save the file.
Step 6: Set Permissions for PageTypeSettings.ss
- In NetSuite, go to Documents > Files > File Cabinet.
- 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.
- Click Edit next to the file, PageTypeSettings.ss.
- Go to the Permission tab and check the Enabled box.
- From the Execute as Role list, select Store Manager.
- Check the Run Script Without Login box.
- Click Save.