This topic contains 0 replies, has 0 voices, and was last updated by KGosnell 9 years ago.

  • Author
    Posts
  • #9722

    KGosnell

    Greetings,

    I have a User Event Script that creates a button on a Sales Order to create a Purchase Order Acknowledgement. (Create PO Ack)

    When the button is clicked it executes a Suitelet that runs a routine to create a CSV file.

    I have a Workflow Action Script that checks availability of items on an incoming purchase order to fulfill or kill an order based on availability.

    I am trying to execute the Suitelet from a Workflow Action Script to automate the “clicking” of the Create PO Ack button.

    My question is the following:

    Is it possible to initiate or execute a Suitelet from a Workflow Action Script ?

    I have been trying to use the nlapiRequestURL function in my Workflow Action Script but it only works with an absolute URL and this is dangerous at best in my opinion.

    I am not seeing anything in the Script Deployment Execution log for the Suitelet either.. Strange even though this line executes without error in my Workflow Action Script..

    nlapiRequestURL(‘https://system.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=123&deploy=1′,null,null,’GET’)

    Is there a better way to execute a Suitelet from a Workflow Action Script ?

    Many thanks in advance..

    Sample of Code……

    Snippet from User Event..

    function userEventBeforeLoad(type, form, request){

    if (type == ‘view’) {

    stID = nlapiGetRecordId();

    //PO Ack button.

    var stSuiteletUrl = nlapiResolveURL(‘SUITELET’, ‘customscript_create_poack’, ‘customdeploy_create_poack’);

    stSuiteletUrl += ‘&param1=’ + stID;

    ………………………………………….. ………………..

    Snippet from Suitelet..

    function suitelet(request, response){

    try {

    nlapiLogExecution(‘DEBUG’,’main’, ‘=====START=====’);

    var stId = request.getParameter(‘param1’) || false;

    if (stId) {

    var stSearchId = nlapiGetContext().getSetting(‘SCRIPT’, ‘custscript_poack_search’);

    var stFilenamePrefix = nlapiGetContext().getSetting(‘SCRIPT’, ‘custscript_poack_prefix’);

    var stDeployment = nlapiGetContext().getSetting(‘SCRIPT’, ‘custscript_poack_desc’);

    ………………………………………….. ………………….

    Snippet from Workflow Action Script..

    function CheckCommitedQty() {

    nlapiLogExecution(‘DEBUG’, ‘Start Script’);

    function isEmpty(e)

    {

    if (null == e) return !0;

    if (“” == e) return !0;

    if (“undefined” == typeof e) return !0;

    if (e instanceof Array && 0 == e.length) return !0;

    if (e instanceof Object) {

    for (var t in e) return !1;

    return !0

    }

    return !0

    };

    Snippet from my test to call a Suitelet from a Workflow Action Script..

    function testCallSuiteletfromWorkflowActionScript() {

    nlapiLogExecution(‘DEBUG’, ‘Start Script’);

    nlapiLogExecution(‘DEBUG’, ‘Call Suitelet’);

    nlapiRequestURL(‘https://system.na1.netsuite.com/app/site/hosting/scriptlet.nl?script=123&deploy=1′,null,null,’GET’) ;

    nlapiLogExecution(‘DEBUG’, ‘End Suitelet Call’);

    nlapiLogExecution(‘DEBUG’, ‘End Script’);

    }
    This is a cached copy. Click here to see the original post.

You must be logged in to reply to this topic.