简体   繁体   English

使用 SuiteScript 2.0 添加客户端脚本以在查看模式下录制

[英]Adding Client Script to Record in View Mode with SuiteScript 2.0

I'm needing to apply a function to a button in NetSuite with a record in "VIEW" mode.我需要将功能应用于 NetSuite 中的按钮,并在“查看”模式下进行记录。 It's simple enough in SuiteScript 1.0 to just attach a client script script during the beforeLoad user event trigger with:在 SuiteScript 1.0 中很简单,只需在 beforeLoad 用户事件触发器期间附加一个客户端脚本脚本:

form.setScript("custscript_script_record_id")

However, with 2.0 it wants either the internal ID of the script file or the path and file name to where the actual file resides within the File Cabinet.但是,在 2.0 中,它需要脚本文件的内部 ID 或实际文件在文件柜中所在位置的路径和文件名。 The issue I have with this approach is being able to bundle the functionality for deployment to another where the internal ID of the file and its path will not be the same as within the account where everything was created.我对这种方法的问题是能够将部署的功能捆绑到另一个文件的内部 ID 及其路径将与创建所有内容的帐户中的不同。 Editing in the installed account will also not be possible due to locking the files to any edits.由于将文件锁定为任何编辑,也无法在已安装的帐户中进行编辑。

If all I'm doing is opening up a scripted form for interaction, this isn't an issue as I can just pass in "window.open(url)" as the button's function.如果我所做的只是打开一个脚本化的表单进行交互,这不是问题,因为我可以将“window.open(url)”作为按钮的功能传入。 The issue is if a URL call or some other activity needs to take place without opening a popup window, or requires more than a simple command.问题在于是否需要在不打开弹出窗口的情况下进行 URL 调用或其他一些活动,或者需要的不仅仅是一个简单的命令。 How can functionality be applied to a button and still be agnostic about values that can chage between accounts?如何将功能应用于按钮并且仍然不知道可以在帐户之间更改的值?

I have a bundled application that uses client scripts.我有一个使用客户端脚本的捆绑应用程序。 This works:这有效:

form.clientScriptModulePath = './clientScript.js';

The bundler flattens your file structure on install.捆绑器在安装时会展平您的文件结构。 You can keep your bundle organized under /Suitescripts/MyBundleDir in the source account but you can't use anything like:您可以在源帐户中的 /Suitescripts/MyBundleDir 下组织您的包,但您不能使用以下内容:

/Suitescripts/MyBundleDir/Part1/clientScript.js
/Suitescripts/MyBundleDir/Part1/ueScript.js

In the installed account it will all be flattended under a single bundle account在已安装的帐户中,它将在一个捆绑帐户下全部展平

/SuiteBundles/bundleId/clientScript.js
/SuiteBundles/bundleId/ueScript.js

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

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