Good morning everyone (well where I am from, What...
# suitescript
c
Good morning everyone (well where I am from, What is the best practice for Creating a custom search and then displaying it on a popup? What I am wanting to do is complete a search and show the results. If the results are approved then they are packaged and sent to an integration. I have everything completed but how to display the results for the user to review and approve. I am currently using a UE script to put a button on the Project form. When the button is clicked it launches a Suitelet script that completes the query and returns everything. I was experimenting with creating a sublist and trying to populate it. I am able to create the columns from the results but I am struggling to create the rows and pass the values. In a perfect world it would behave like the Items sublist on a Sales Order TL:DR Best practice for showing Survey results in a popup.
b
share the code
and errors
b
You should be able to create a sublist in your Suitelet form and populate it.
c
Here is the snippet of code.
Copy code
var searchResults = SearchObj.run(); //SearchObj is a created Search

            searchResults.columns.forEach(function(col){
                list.addField({
                    id: col.name,
                    label: col.label,
                    type: serverWidget.FieldType.TEXT
                });
            });

            for(var i in results){ //results is the same search paramaters as SearchObj but uses .Run().each and builds an array
                var result = results[i];
                for(var k in result.columns){
                    var test = result.columns[k];
                    var fieldValue = result.getValue(result.columns[k])

                    var a = Number(i);   
                    var n = result.columns[k].name;
                    var nn = fieldValue;
                    list.setSublistValue({
                        id: result.columns[k].name,
                        value: fieldValue,
                        line: a                       
                        });
                }
            } //errors after one loop through.
This is the error I get
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "SSS_MISSING_REQD_ARGUMENT",
  "message": "Sublist.setSublistValue: Missing a required argument: options.value",
  "id": null,
  "stack": [
    "Error",
    " at testForm (/SuiteScripts/sl.js:140:26)",
    " at Object.onRequest (/SuiteScripts/sl.js:43:25)"
  ],
  "cause": {
    "name": "SSS_MISSING_REQD_ARGUMENT",
    "message": "Sublist.setSublistValue: Missing a required argument: options.value"
  },
  "notifyOff": false,
  "userFacing": true
}
b
as a general warning, that is one of the better error messages you will get out of netsuite
Copy code
list.setSublistValue({
  id: result.columns[k].name,
  value: undefined,
  line: a,
});
using the above instead will give you a better idea of whats happening, but you should have been able to identify that something was wrong with the value parameter
c
Thank you, I was able to modify the code to work. The error was trying to add a empty string value to a serverWidget.FieldType.TEXT type in the sublist.