Trying to build a Script Search that will pull in ...
# suitescript
j
Trying to build a Script Search that will pull in basic account data. Is it correct to assume I'm only able to build a Scripted Search using the
Search Columns
found on the
Records Browser
? https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2022_1/script/record/account.html
keep getting similar errors on almost every column I try to add:
Copy code
{"type":"error.SuiteScriptError","name":"SSS_INVALID_SRCH_COL","message":"An nlobjSearchColumn contains an invalid column, or is not in proper syntax: {fieldId=name}.
e
You would also be able to pull custom fields on that record type and fields on related records.
If you can post your search code, someone can probably identify the issue.
j
Copy code
function getDataBySearch() {

            var data = [];
            var filters = [];
            var columns = [];

            filters.push(search.createFilter({
                name: 'isinactive',
                // join: 'employee',
                operator: <http://search.Operator.IS|search.Operator.IS>,
                values: 'F'
            }));

            var colData = {
                INTERNAL_ID: {fieldId: 'internalid'}, // SSS_INVALID_SRCH_COL
                ACCT_NUM: {fieldId: 'acctnumber'}, // SSS_INVALID_SRCH_COL
                ACCT_NAME: {fieldId: 'name'}, // SSS_INVALID_SRCH_COL
                PARENT: {fieldId: 'parent'}, // SSS_INVALID_SRCH_COL
                PARENT_NUM: {fieldId: 'custrecord_plx_prnt_account_number'},
                PARENT_ID: {fieldId: 'custrecord_plx_parent_internal_id'},
                PARENT_NAME: {fieldId: 'custrecord_plx_parent_account_nm'}
            };
            for (var col in colData) {
                columns.push(search.createColumn(colData[col]));
            }

            search.create({
                type: search.Type.ACCOUNT,
                filters: filters,
                columns: columns
            }).run().each(function (result) {

                var line = {};
                for (var col in colData) {
                    line[col] = result.getValue(colData[col]);
                }
                data.push(line);

                return true;
            });

            return data
        }
e
I think the problem is that the result.getValue() method is expecting a string which should be the column name and not an object. In your colData variable, try just using the column name instead of using an object for each field.
🙏 1
s
For simple data columns, you don't need to do a createColumn call, you can pass a simple array and the search.create will turn them into columns for you
e
it’s
name
and not
fieldId
even though you would think it should be!
j
Yeah thanks @ec I got it confused with the query module