Below is my search var assigneeID = search.create(...
# suitescript
v
Below is my search var assigneeID = search.create({ type: "employee", filters: [ ["entityid","is",assigneeName] ], columns: [ search.createColumn({name: "internalid", label: "Internal ID"}) ] }); i get the below for the search {"type":"employee","id":-1,"filters":[{"name":"entityid","operator":"is","values":["Arnold Hutchings"],"isor":false,"isnot":false,"leftparens":0,"rightparens":0}],"columns":[{"name":"internalid","join":null,"summary":null,"label":"Internal ID","type":null,"function":null,"formula":null,"sortdir":"NONE","whenorderedby":null,"whenorderedbyjoin":null,"whenorderedbyalias":null}],"settings":null,"title":null,"scriptId":null,"isPublic":false,"packageId":null} I need the internal id, what is wrong with this? could anyone please help?
n
you have to run the search in the script after you create it
Copy code
var assigneeID = search.create({
            type: "employee",
            filters:
                [
                  ["entityid","is",assigneeName]
                ],
            columns:
                [
                  search.createColumn({name: "internalid", label: "Internal ID"})
                ]
          });
          
          let assigneeInternalId;
          assigneeID.run().each(result => {
            assigneeInternalId = result.id;
            return false;
          })
oh that has an arrow function in it. You can either change the suitescript version at the top to 2.1 (recommended) or you can do it like this
Copy code
var assigneeID = search.create({
            type: "employee",
            filters:
                [
                  ["entityid","is",assigneeName]
                ],
            columns:
                [
                  search.createColumn({name: "internalid", label: "Internal ID"})
                ]
          });

          var assigneeInternalId;
          assigneeID.run().each(function (result) {
            assigneeInternalId = result.id
            return false;
          });
v
Thankyou sir