我有一个Suitecommerce网站产品页面,其中某些信息以查询参数的形式附加到网址。例如: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网址的salesOrder记录。
我想到的一个解决方案是将url参数放在浏览器的本地存储中,然后从suitescript中获取它。但Suite脚本无法识别qazxsw poi。
知道我怎么能做到这一点?代码片段会很有帮助。
在引荐的场景中,如果每个订单需要一个,您可以创建一个事务正文字段,并在将项目添加到购物车时从前端填充该字段。
如果您需要按项目引用代码,则必须创建“交易项目选项”并手动将URL中的“值”添加到该字段中。
如果您要读取URL参数并将其保存到NetSuite Backend字段中,请使用XSS Injection进行超级小心,请在保存之前转义任何值并确认该值是否正确。