Hello Team,
When I log searchResult[index], the data is returned correctly. However, when I try to access searchResult[index].values or searchResult[index].values['GROUP(salesrep)'], the result is blank (I am using savedSearch)
Here is the code I’m using:
/** * @NApiVersion 2.x * @NScriptType UserEventScript * @NModuleScope SameAccount */define(['N/email', 'N/record', 'N/runtime', 'N/log', 'N/search'], function(email, record, runtime, log, search) { function beforeSubmit(context) { try { // Load the saved search var savedSearch = search.load({ id: 'customsearch911' }); // Run the saved search var searchResult = savedSearch.run().getRange({ start: 0, end: 1000 }); for (var index = 0; index < searchResult.length; index++) { log.debug({ title: 'Sales Rep and Group Information', details: searchResult[index].values }); } } catch (e) { log.error('Error loading saved search', e.message); } } return { beforeSubmit: beforeSubmit };});
Here’s the response I’m getting from the saved search:
[ { "values":{ "GROUP(salesrep)":[ { "value":"5067", "text":"Abraham" } ], "GROUP(custbody21)":[ { "value":"2", "text":"Partner" } ], "SUM(custbody39)":"400000.00" } }, ... { "values":{ "GROUP(salesrep)":[ { "value":"5068", "text":"Yousef" } ], "GROUP(custbody21)":[ { "value":"1", "text":"Direct Sales" } ], "SUM(custbody39)":"4850000.00" } }]
Thank you in advance for any guidance you can offer!