Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 3cd36b0

Browse files
Chore: Two fixes in N/Search, Utils/Record (#11)
* recordModule Added new fuction `insertLine` * Search-module Fixes
1 parent f06d4ab commit 3cd36b0

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

N/search.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function createFilter(options) { // eslint-disable-line no-unused-vars
3030
* @returns {object} resultset
3131
*/
3232
function ResultSet() {
33-
const privateColumns = this.columns || {};
33+
const privateColumns = this.columns || [];
3434
const times = this.type === 'customrecord_mycs_script_settings' ? 1 : Math.floor(Math.random() * 99) + 1;
3535
const mockupData = _.map(_.times(times), item => ({
3636
id: item + 1,
@@ -104,6 +104,23 @@ function ResultSet() {
104104
};
105105
}
106106

107+
/**
108+
* NetSuite new column
109+
* @param {*} options
110+
* @returns {string}
111+
*/
112+
function createColumn(options) {
113+
return `${ options.name }${ options.join ? '__' + options.join : '' }`;
114+
}
115+
116+
/**
117+
* NetSuite new filter
118+
* @param {*} options
119+
* @returns {string}
120+
*/
121+
function createFilter(options) { // eslint-disable-line no-unused-vars
122+
return `${ options.name }${ options.join ? '__' + options.join : '' }`;
123+
}
107124
/**
108125
* NetSuite - constructor of search module.
109126
* @param {*} options_
@@ -145,10 +162,13 @@ module.exports = {
145162
createColumn: options => createColumn(options),
146163
lookupFields: (options) => {
147164
const result = {};
148-
options.columns.map((item, index) => {
149-
result[item] = [{ value: index, text: item }];
150-
return true;
151-
});
165+
if (Array.isArray(options.columns)) {
166+
options.columns.map((item, index) => {
167+
result[item] = [ { value: index, text: item } ];
168+
});
169+
} else if (typeof options.column === 'string') {
170+
result[options.column] = [ { value: Math.floor(Math.random() * 10000), text: options.column } ];
171+
}
152172
return result;
153173
},
154174
Type: {

Utils/record.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ function NsRecord(name, defaultValues = {}) {
6868
insertLineItem: (sublist, index) => {
6969
this.values[sublist].splice(index - 1, 0, {});
7070
},
71-
71+
insertLine: options => {
72+
this.values[options.sublistId].splice(options.line, 0, {});
73+
},
7274
removeLine: (obj) => {
7375
this.values[obj.sublistId].splice(obj.line, 1);
7476
},

0 commit comments

Comments
 (0)