I have a NetSuite Suitelet that will render the page using an HTML file, with a data source coming in within the Suitelet:
var renderer = render.create();
renderer.templateContent = file.load(<file id>).getContents();
renderer.addCustomDataSource({format:render.DataSource.OBJECT, alias:"DATA", data: DATA});
renderer.renderToResponse({response:scriptContext.response});
In the HTML code, there are 2 select fields which should list down transaction numbers from NetSuite:
<select id="workorderIDInput" name="workorderIDInput">
<option value="">Select a Work Order</option>
</select>
I wanted to use a search in the Suitelet, and have the search results to be used in the HTML as select options. I am already gathering the transaction numbers via search, and adding that array to the “DATA” data source of the renderer:
var workorders = loadWorkOrders();
function loadWorkOrders(scriptContext){
try {
var workOrderIds = [];
var searchId = 6427;
// var currentScript = runtime.getCurrentScript();
// var searchId = currentScript.getParameter({
// name: 'custscript_wo_search_id'
// });
var woSearch = search.load({
id: searchId
});
woSearch.run().each(function(result){
var woTranNum = result.getValue('tranid');
workOrderIds.push(woTranNum);
return true;
});
// log.debug('Work Order IDs', workOrderIds);
return workOrderIds;
} catch (e) {
log.error('loadWorkOrders error', e);
}
}
Is this possible to achieve? There is another approach where I will be calling an endpoint to give the array and loop through and create option elements from chatGPT, but I’m still trying to make it work. This question seems to be on the direct approach without creating a separate endpoint to get the values I need for the dropdown
There is another approach where I will be calling an endpoint to give the array and loop through and create option elements from chatGPT, but I’m still trying to make it work. This question seems to be on the direct approach without creating a separate endpoint to get the values I need for the dropdown
FHTPG_Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.