Hello, I keep on getting a script error that the i...
# suitescript
p
Hello, I keep on getting a script error that the id is missing. I am trying to pull results from a grouped saved search. What am I doing wrong? var resultRange = searchResult.getRange({ start0,end 1000 }).forEach(function(result){ //var itemid = result.id; var itemid = result.getValue("Internal ID"); var soid= record.load({ type: record.Type.INVOICE, id: itemid, isDynamic: false });
c
Copy code
var resultRange = searchResult.getRange({ start:0,end: 1000
		}).forEach(function(result){
                //var itemid = result.id;
                var itemid = result.getValue({name: 'internalid'}); // Assuming 'internalid' is search column otherwise result.id should work IFF result is an Item search result.
    		var soid= record.load({
                type: record.Type.INVOICE,
                id: itemid,
                isDynamic: false
            }); (edited)
s
Specifically, getValue does not take a string as a parameter
In general, your variable name makes no sense,
itemid
and then loading an invoice (that is called
soid
?). I would recommend not using really confusing names like that.
w
@creece, result.id won't work in a grouped search iirc.
s
That would make sense
w
You need to add the column and set it as grouped to be able to retrieve it.
p
thanks for the help. I changed it to result.getValue(result.columns[0]); and it worked
m
Do you need to load every record from your search results? I can see this quickly running out of governance. I'd suggest adding the fields you need to this or a second search
p
would it be possible to set the header fields and not open up the record? I have the fields I need from the search
m