如何获取当前suitelet的url

时间:2017-05-05 12:06:51

标签: netsuite suitescript

我正在使用suitecript 2.0,我需要知道是否有办法在运行时获取套件的url?

2 个答案:

答案 0 :(得分:3)

对于外部网址,您可以执行以下操作:

require(['N/runtime', 'N/url'], function(runtime, url){
    var cs = runtime.getCurrentScript();
    var scriptURL = url.resolveScript({
      scriptId: cs.id,
      deploymentId: cs.deploymentId,
      returnExternalURL: true
    });

如果获得内部URL,则可能还必须将host和scheme添加到返回的根相对值。在2017.1版本中,url将有一个url.resolveDomain方法,可以让您查找主机。

答案 1 :(得分:1)

function onRequest(context) {
          log.debug({
    title: 'context',
    details: context.request.method
});
      if (context.request.method === 'GET') {
 fil = context.request.parameters.employee
        log.debug({
    title: 'url',
    details: fil
});
 }

这样做.......... 如果您希望在脚本运行或被调用时获取脚本参数。