使用suitescript访问netsuite html表单的当前用户信息 [英] Accessing current user information for a netsuite html form using suitescript

查看:122
本文介绍了使用suitescript访问netsuite html表单的当前用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将netsuite的某些值自动完成到我们的自定义html表单上.

I've been trying to figure auto-complete some values from netsuite onto our custom html form.

经过一番研究,我发现了这个宝石:nlapiGetContext(

After a bit of researching, I found this gem: nlapiGetContext (http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html)

应该完全按照说的做,

但是,在执行nlapigetcontext()的console.log转储时

However, when doing a console.log dump of nlapigetcontext()

显示以下信息,而不是我当前登录的用户信息

the following information is displayed, not my current logged in user information

这是我当前的测试脚本:

Here is my current test script:

if (window.addEventListener) { // Mozilla, Netscape, Firefox
    window.addEventListener('load', WindowLoad, false);
} else if (window.attachEvent) { // IE
    window.attachEvent('onload', WindowLoad);
}

function WindowLoad(event) {
   alert(nlapiGetContext().getCompany());
   console.log(nlapiGetContext());
}

任何帮助或指导表示赞赏!

Any help or guidance is appreciated!

谢谢!

推荐答案

此表单位于何处?上下文仅在您登录系统后才起作用,因此这不适用于在线客户表单,这些表单被认为是系统外部".

Where is this form located? Context will only work if you are logged into the system, so this won't apply for online customer forms, those are considered to be "outside the system".

如果只检索值,则可以编写Suitelet来从外部表单检索数据.

You can write a Suitelet to retrieve data from an external form if you are only retrieving values.

我用它来在外部目标网页上获取广告系列信息.

I use this to get campaign information on an external landing page.

function getCamData(request, response){
if ( request.getMethod() == 'GET' ){
    response.setHeader('Custom-Header-CamID', 'CamID');
    var camid = request.getParameter('camid');
    var rec = nlapiLoadRecord('campaign', camid);
    var o = new Object();
        o.thisid = camid; 
        o.promocode = rec.getFieldValue('campaignid'); 
        o.phone = rec.getFieldValue('custevent_cam_1300num');
        o.family = rec.getFieldValue('family');
        var myString = JSON.stringify(o);       
        response.write (myString);
}}

您请求这样的内容:

https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=188&deploy=1&compid=xxxxxx&h=fb8224b74b24907a79e6&camid=8020

并返回如下内容:

{"thisid":"8020","promocode":"CAM999","phone":"1800 111 222","family":"12"}

{"thisid":"8020","promocode":"CAM999","phone":"1800 111 222","family":"12"}

此外,您还可以从外部站点到NetSuite客户在线表单进行服务器端发布,只要它在NS中设置了输入字段,它就会捕获并验证数据,这是避免使用这些表单的一种好方法可怕的iframe.

Also you can do server-side posting from an external site to a NetSuite customer online form, it will capture and validate the data as far as it has the entry fields set in NS, this is a great way to avoid using those horrible iframes.

这篇关于使用suitescript访问netsuite html表单的当前用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆