This topic contains 4 replies, has 0 voices, and was last updated by mwhite@hgyp.com 7 years ago.

  • Author
    Posts
  • #17877

    ajrey77

    I’m running a scheduled script that runs out of governance about half way through the record set. How do I capture the last record processed and then tell the script to restart at the next result in the search?
    This is a cached copy. Click here to see the original post.

  • #17878

    khultquist

    Two ways to handle it:

    1. in your results loop, add a condition that the nlapiGetContext().getRemainingUsage() > some value that will prevent partial execution. Then schedule the script to run again. This works if a record is removed from your search results after being edited by the script.

    2. use nlapiSetRecoveryPoint() or nlapiYieldScript()


    ajrey77 replied on 10/23/2017, 03:54 PM: How would that occur in SS 2.0?

  • #17879

    pcutler

    khultquist Is correct, those are both good approaches. Other approaches would include a mass update script or a map/reduce script since governance limits are for each record.

    As far as more details on a simple solution (applies to ss 1.0 or 2ss 2.0):Create a checkbox on the record type your processing
    Create a saved search of records to process that excludes records with the checkbox checked
    Write your script to process results from the saved search
    Have your script check the remaining usage and reschedule itself when less than x governance points remaining. The amount depends on how many governance points you need per record. Scheduling scripts is in the N/task module.

  • #17880

    Vesku1980

    Hi

    Can you share your script?

    It is possibile that you do something that can ne done different way to use less usage points.

    Vesku

  • #17881

    mwhite@hgyp.com

    I agree with @pcutier. Using a Saved Search as your work queue is definitely the way to go. If that’s not possible for some reason, I would recommend a custom record to save the starting point and calculations in progress.

You must be logged in to reply to this topic.