简体   繁体   中英

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. It's simple enough in SuiteScript 1.0 to just attach a client script script during the beforeLoad user event trigger with:

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. 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. 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. 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. 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/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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