我有一个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);
}但我还想传递来自suitecommerce url的referralId和salesOrder记录。
我想到的一个解决方案是将url参数放在浏览器的本地存储中,然后从suitescript中获取它。但是套件脚本不能识别window.localStorage。
你知道我该怎么做吗?一个代码片段会很有帮助。
发布于 2019-04-28 22:33:53
在推荐的场景中,如果每个订单需要一个字段,您可以创建一个事务主体字段,并在将商品添加到购物车时从前端填充该字段。
如果您需要逐项添加推荐代码,则必须创建一个事务处理项选项,并手动将URL中的“值”添加到该字段中。
如果您要读取URL参数并将其保存到NetSuite后端字段中,请使用XSS Injection进行超级小心,转义任何值并在保存之前确认该值是正确的。
https://stackoverflow.com/questions/54141137
复制相似问题