Create search inside a loop

It seems like you are using search API inside the loop and consumes a lot of governance that would affect the user interaction which is not a good practice.

good practice :

Create the search inside a function the search result stored to an object format and call it when required,

Example :

 const mapItemOpt = () => {   

    let Search = search.create({     

          type:, 

        filters:         

columns:  )} 

          let OptionObj = {};           

Search.run().each(function (result) {OptionObj[“key”] = { “key”: value, “key”: value }               

return true;           

});           

return OptionObj;   

  };

Leave a comment

Your email address will not be published. Required fields are marked *