简体   繁体   English

NetSuite SuiteScript 2.0 获取公司名称

[英]NetSuite SuiteScript 2.0 get Company Name

Is there any way to get the current company name when on a transaction entry page?在交易输入页面上,有什么方法可以获取当前的公司名称? Either some session object, global object, or some sort.某个会话对象、全局对象或某种类型。 Kind of like how you can get the user name from the runtime module?有点像如何从运行时模块获取用户名? I see country name, but cannot seem to get the company name.我看到国家名称,但似乎无法获得公司名称。 Using a client script for this.为此使用客户端脚本。

How I get the user name:我如何获取用户名:

runtime.getCurrentUser().name runtime.getCurrentUser().name

thank you谢谢你

Here is the working code now, but trying to figure a way to get this on a client script.这是现在的工作代码,但试图找到一种在客户端脚本上获取它的方法。 Possible to pass this value?可以传递这个值吗?

    var companyInfo = config.load({
        type: config.Type.COMPANY_INFORMATION
    });
    
    var compname = companyInfo.getValue({
        fieldId: 'companyname'
    });
    
    log.debug(compname);
    
    scriptContext.form.addButton({
        id: "custpage_mybutton",
        label: "View Documents",
        functionName: "onButtonClick"
    });
    scriptContext.form.clientScriptModulePath = "SuiteScripts/dl_cs_vendorbill.js";

In server side scripts you can do this:在服务器端脚本中,您可以这样做:

require(['N/config'], config=>{
   const info = config.load({type:config.Type.COMPANY_INFORMATION});
    log.debug({title:'Current company Info', details:info.getValue({fieldId:'companyname'}));
});

For a client script you could use that code in a paired user event script.对于客户端脚本,您可以在配对的用户事件脚本中使用该代码。 In the before phase of the UE you'd do the lookup and then add a hidden field to the form with the company name as a value.在 UE 的前阶段,您将进行查找,然后将隐藏字段添加到表单中,并将公司名称作为值。 Your client script can then look that up like any normal getValue然后,您的客户端脚本可以像任何普通的getValue一样查找它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM