This topic contains 7 replies, has 0 voices, and was last updated by j.j 8 years, 3 months ago.

  • Author
    Posts
  • #6218

    MarkZSSI

    Are there any tips on how to optimize the code where there are a lot of searches and submit records that would cause you to blow through the governance limits that NS sets? I thought about shoving all the results into an array in the loop and doing the submit after the loop, but that doesn’t seem to work at all.

    Any other ways to do this?
    This is a cached copy. Click here to see the original post.

  • #6219

    david.smith

    I do the seach(s) and stick what I need into an object. From there I will parse out the data. I very rarely use an array because that just causes to many loops. I think you’re on the right track. Best practice would be to never have a search/lookup in a loop if you can avoid it.

  • #6220

    MarkZSSI

    Originally posted by david.smith

    View Post

    I do the seach(s) and stick what I need into an object. From there I will parse out the data. I very rarely use an array because that just causes to many loops. I think you’re on the right track. Best practice would be to never have a search/lookup in a loop if you can avoid it.

    Thanks for the response. I think I’ll give that a try tomorrow.

  • #6221

    Nelliott

    If it’s something you can schedule you might also consider a mass update script.

    Not sure if this would meet your needs but I thought I’d throw it out there for you to consider.

  • #6222

    MarkZSSI

    Originally posted by Nelliott

    View Post

    If it’s something you can schedule you might also consider a mass update script.

    Not sure if this would meet your needs but I thought I’d throw it out there for you to consider.

    Any reason you would say that?

  • #6223

    Nelliott

    Originally posted by MarkZSSI

    View Post

    Any reason you would say that?

    The governance on a mass update is such that you’re extremely unlikely to run out of governance. It’s allocated on a per record basis.

    From the NS Help : “The SuiteScript governance limit is 1000 units per record/ invocation of a mass update script.”

  • #6224

    CREECE

    The best thing to do is get ALL data that is needed into some object and then act on said data. You can utilize the nlapiYield function that will preserve your running logic for a subsequent governance set. Without seeing what else you are doing, it is hard to say what you can do for optimization.

  • #6225

    j.j

    it all depends on the volumes and the exact need. i had tremendous amount of data crunching needed and that meant re-running/re-scheduling the script due to governance limits, the best i could work out was to create a temp file and store data in it, re-read process re-write till the entire set of operations is completed. hope this helps

You must be logged in to reply to this topic.