我有一个 Suitecommerce 网站产品页面,其中某些信息以查询参数的形式附加到 url。例如:https://my-ecommerce.com/product/someProduct?referralId=someValue
我的目标是salesOrder
在产品购买时将记录传递给一些外部 API 端点。我通过如下部署用户事件脚本来实现这一点:
function afterSubmit(type) {
// Url of the external api endpoint to push data
var url = "http://external-url/endpoint/";
// Get the new created record. It returns a nlRecordObj
var record = nlapiGetNewRecord();
// Get the record Id of that created record
var recordId = record.getId();
// Get the record of corresponding record Id and record type
var nlobj = nlapiLoadRecord("salesOrder",recordId);
// To log our request data
nlapiLogExecution("DEBUG","Test",JSON.stringify(nlobj));
// Set Headers for HTTP request
var headers = {"Content-Type":"application/json"};
// Performing HTTP request to our url with our newly created data as payload
var response = nlapiRequestURL(url, JSON.stringify(nlobj), headers);
}
但我还想传递的是referralId
来自suitecommerce url 的salesOrder 记录。
我想到的一种解决方案是将url参数放在浏览器的本地存储中,然后从suitescript中获取它。但 Suite 脚本无法识别window.localStorage
。
知道我怎么能做到这一点吗?一个代码片段会很有帮助。