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

  • Author
    Posts
  • #1546

    kiko

    Hi, How do I call a suitelet written in 2.0 on the afterSubmit function (user event) written in 1.0

    Note that I also need to pass some parameters to the 2.0 suitelet.

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

  • #1547

    david.smith

    nlapiResolveURL(‘suitelet’……)

    nlapiRequestURL(….)

  • #1548

    chanarbon

    Agreeing with david.smith, you should use nlapiResolveURL() then append the parameters to the result of the resolved URL then perform the request url. But please note that you should have the same data center. This should be just the same on how you call it on 1.0 to 1.0

  • #1549

    elie

    chanarbon What’s the recommended way to accomplish getting the appropriate data center url? (In a User Event script, not web service)

  • #1550

    david.smith

    elie You can get the URL in the beforload script context using the server request object.


    elie replied on 05/24/2017, 02:36 PM: David,

    Are you suggesting storing it in a custom scripted field so that it is accessible on the backend afterSubmit?

    Can you share some code? Thanks!

  • #1551

    david.smith

    Code:
    /**
    * @NApiVersion 2.x
    * @NScriptType UserEventScript
    */
    define([‘N/search’,’N/ui/serverWidget’],
    function(search, serverWidget) {

    function beforeLoad(scriptContext) {
    log.debug(‘context’,scriptContext);

    var form = scriptContext.form;
    var hiddenFld = form.addField({
    id:”custpage_ns_url”,
    label:”Domain URL”,
    type:’text’
    });
    var domain = scriptContext.request.url.replace(/https:///,”).replace(//.+/,”);
    hiddenFld.defaultValue = domain;
    hiddenFld.updateDisplayType({
    displayType : ‘hidden’
    });
    }

    function afterSubmit(scriptContext) {
    var newRec = scriptContext.newRecord;
    log.debug(‘domain’,newRec.getValue({fieldId:’custpage_ns_url’}));
    }

    return {
    beforeLoad: beforeLoad,
    // beforeSubmit: beforeSubmit,
    afterSubmit: afterSubmit
    };

    });

You must be logged in to reply to this topic.