This topic contains 2 replies, has 0 voices, and was last updated by david.smith 7 years, 9 months ago.

  • Author
    Posts
  • #1200

    WakaWaka

    I am trying to find all deployments for a script that aren’t scheduled and then use one of them to run the script immediately. In SS1.0 it seems like you could call nlapiScheduleScript and it would automatically pick an available deployment. If there were none available, nlpapiScheduleScript returned the status of the script, and if it wasn’t QUEUED then you could create a new deployment or do whatever is needed. In SS2.0 it seems like you have to try submitting the task and then catch the error for when no deployments are available. To me, that seems hackish and not a good idea.

    What I’ve been trying to do is do a search for all deployments of the script that are not queued. This is the code I am using:

    Code:
    //find the available script deployments
    var search = nsSearch.create({
    type: nsSearch.Type.SCRIPT_DEPLOYMENT,
    filters: [
    [‘script.scriptid’, ‘is’, scriptId],
    ‘AND’,
    [
    [‘status’, ‘is’, ‘NOTSCHEDULED’]
    ]
    ],
    columns: [{
    name: ‘scriptid’
    },
    {
    name: ‘status’
    }]
    });
    What I am running into is that each deployment returns with a status of NOTSCHEDULED. So then I specify the script id of one of the results as the deploymentId when I create the script. However, this errors out when I loop through my code for the second time. Clearly, the search is not returning deployments that are fit for scheduling and/or running. This is the error I get, minus the stacktrace:

    Code:
    {“type”:”error.SuiteScriptError”,”name”:”FAILED _TO _SUBMIT_JOB_REQUEST_1″,”message”:”Failed to submit job request: INQUEUE.”
    If the status is INQUEUE, then I shouldn’t be getting that deployment in my search results, right? What am I doing wrong? Any advice would be greatly appreciated!
    This is a cached copy. Click here to see the original post.

  • #1201

    Olivier Gagnon NC

    Yeah we’re doing the same. Give it a shot and catch the error. No, no ideal. “Not ideal” kind of sums up all of SS2.0 though.

  • #1202

    david.smith

    Code:
    var scriptdeploymentSearchObj = search.create({
    type: “scriptdeployment”,
    filters: [
    [“script”,”anyof”,”587″],
    “AND”,
    [“status”,”anyof”,”NOTSCHEDULED”]
    ],
    columns: [
    search.createColumn({
    name: “title”,
    sort: search.Sort.ASC
    }),
    “scriptid”,
    “script”,
    “recordtype”,
    “status”,
    “isdeployed”,
    “scripttype”,
    “ismobilemenu”
    ]
    });
    scriptdeploymentSearchObj.run().each(function(result){
    return true;
    });

You must be logged in to reply to this topic.