javascript - 如何在 SuiteScript 1.0 中使用 sendRedirect 添加额外参数?

标签 javascript url redirect netsuite suitescript

我是 SuiteScript 新手,我似乎无法完全理解在重定向上添加 url 参数。我知道SuiteScript 1.0文档说明可以根据这个函数添加额外的参数:

sendRedirect(类型、标识符、id、编辑模式、参数)

type {string} [required] - The base type for this resource

identifier {string} [required] - The primary id for this resource (record type ID for RECORD, scriptId for SUITELET, taskId for tasklink, url for EXTERNAL)

id {string} [optional] - The secondary id for this resource (record type ID for RECORD, deploymentId for SUITELET)

editmode {boolean true || false} [optional] - For RECORD calls, this determines whether to return a URL for the record in edit mode or view mode. If set to true, returns the URL to an existing record in edit mode, otherwise the record is returned in view mode.

parameters {hashtable} [optional] - An associative array of additional URL parameters as name/value pairs

但是我对最后第四个参数感到非常困惑,其中文档指出需要关联数组。我尝试编写此代码来测试添加该参数。

function suitelet(request, response) {
    var arrayParam = [];
    arrayParam.push({custparam_key: 'value'});
    response.sendRedirect('SUITELET', 'customscript_a', 'customdeploy_a', 
    arrayParam);
}

但我无法追踪最后一个参数在我的 Suitelet 中的位置。上面的代码确实允许用户使用其他默认参数重定向回相同的表单本身。但我不想要相同的默认参数。我希望能够在某些需要重定向用户的情况下创建额外的自定义参数。

我希望这一切都有道理。我觉得也许我不明白最后一个参数的用途。如果是这样,那么任何澄清都会有帮助!

最佳答案

像这样创建关联数组:

 params['custparam_test1'] = value_test1;

然后就得到这个:

var param = request.getParameter('custparam_test1')

在您的代码中,arrayParam[0] 中有一个对象,它是零位置,但它不是关联数组。

关于javascript - 如何在 SuiteScript 1.0 中使用 sendRedirect 添加额外参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54624222/

相关文章:

c 正则表达式代码不起作用?

javascript - Electron :关闭 w X vs 右键单击​​停靠并退出

javascript - D3 在 X 轴上平移直线时,沿 mousemove 中断的路径移动圆

apache - 将 URL 重定向到新地址但保留原始地址

php - 如何获取Params类型的数组

post - Rails 3 使用 POST 重定向

javascript函数在到达特定网址时重定向?

java - 表单提交thymeleaf和Spring boot后如何保持在同一页面?

javascript - 如何将数字分成整数部分,每个部分都是n的倍数?

javascript - SyntaxError 的 jQuery parseJSON 帮助