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

  • Author
    Posts
  • #18340

    jmacdonald

    Hello,

    I am trying to call a suitelet from within a UE script and I’m running into some weird errors. I generate the url by using url.resolveDomain and url.resolveScript and then use https.get to make the call. The response returned is the NetSuite login page with the message “Your session has timed out. Please log in again.” I have tried everything I can think of to get this to work, using http instead of https, running as admin, making available without login and deploying to all roles. Is there something I’m missing? anyone have any ideas?

    Cheers, Jamie.
    This is a cached copy. Click here to see the original post.

  • #18341

    volneiferreira

    Which entry point of UE are you trying call the suitelet?

    In beforeLoad I did a simple test and work fine:

    Code:
    var urlToCall = url.resolveScript({
    scriptId: ‘customscript_test’,
    deploymentId: ‘customdeploy_test’,
    returnExternalUrl: true
    });

    log.debug({
    title: ‘urlToCall’,
    details: urlToCall
    });

    var response = https.get({
    url: urlToCall
    });

    log.debug({
    title: ‘Client Response Body’,
    details: response.body
    });

  • #18342

    jmacdonald

    Originally posted by volneiferreira

    View Post

    Which entry point of UE are you trying call the suitelet?

    I’m using beforeSubmit @volneiferreira

    Code:
    // Get the domain for the https call

    var domain = url.resolveDomain({

    hostType: url.HostType.APPLICATION

    });

    log.debug(‘domain’, domain);

    // Get the URL for the suitelet

    var csvGenerationUrl = url.resolveScript({

    scriptId: ‘customscript_neteur002_sl_generatecsv’,

    deploymentId: ‘customdeploy_neteur002_sl_generatecsv’,
    params: {
    contractid : contractId
    }
    });

    log.debug(‘csvGenerationUrl’, csvGenerationUrl);

    var link = “https://” + domain + csvGenerationUrl;

    log.debug(‘link’, link);

    // Http call to suitelet

    var success = https.get({
    url: link
    });
    I would prefer to call this using the internal url, should I instead be using the external url if this is from a script?

  • #18343

    jmacdonald

    I tried using the external url and found it worked. Not sure what I was doing wrong trying the internal url but oh well, at least it works now. Thanks for the code example!

  • #18344

    volneiferreira

    I’m not sure why it only works with the external url but you could create a library that was used by Suitelet and UserEvent

    instead.

You must be logged in to reply to this topic.