I am using strong soap in node to extract a saved search in Netsuite. I have had some success but now I have the information in node I need to extract the values.
If I use util.inspect on the results of the search query then I get a long detailed breakdown of all the information in the search.
If I just use console.log to print the results then I get the below.
The information I need is inside the entityId and customFieldList objects.
How do I go about accessing these objects?
[
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
},
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
},
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
},
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
},
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
},
{
'$attributes': { '$xsiType': [Object] },
basic: { entityId: [Object], customFieldList: [Object] }
}
]
Thank you for the effort to help so far.
when I use util.inspect then each of the above sections breaks down like the below. I have asterisks the sensitive info, but essentially the values I need are the searchValue for entityId and customField.
{
status: { '$attributes': { isSuccess: 'true' } },
totalRecords: 6,
pageSize: 1000,
totalPages: 1,
pageIndex: 1,
searchId: '****************************************************************',
searchRowList: {
searchRow: [
{
'$attributes': {
'$xsiType': {
type: 'EmployeeSearchRow',
xmlns: 'urn:employees_2022_2.lists.webservices.netsuite.com'
}
},
basic: {
entityId: { searchValue: '*****' },
customFieldList: {
customField: [
{
'$attributes': {
internalId: '****',
scriptId: 'custentity_revenuetoday_stored',
'$xsiType': {
type: 'SearchColumnDoubleCustomField',
xmlns: 'urn:core_2022_2.platform.webservices.netsuite.com'
}
},
searchValue: '*****'
},
{
'$attributes': {
internalId: '****',
scriptId: 'custentity_wallboard_yn',
'$xsiType': {
type: 'SearchColumnBooleanCustomField',
xmlns: 'urn:core_2022_2.platform.webservices.netsuite.com'
}
},
searchValue: 'true'
}
]
}
}
},
Sebastian's answer below is what you need if you get the same problem. Code I used of his was:
const searchRows = result.searchResult.searchRowList.searchRow;
searchRows.forEach((row) => {
const searchValue = row.basic.entityId.searchValue;
const customField = row.basic.customFieldList.customField.searchValue;
console.log(searchValue);
console.log(customField);
});