RE: What is the best method of passing values from BeforeSubmit to AfterSubmit portion of a User Event Script.


My objective is to pass values from the BeforeSubmit and use it in the AfterSubmit portion of a User Event Script.

After reading some doc, I found the Cache module was a viable option. But is it the best method?

Context of full script below: automate the following workaround to apply a Credit Memo to a Cash Sale  before Credit Card gateway process.


var myCache = cache.getCache({

name: 'temporaryCache',

scope: cache.Scope.PRIVATE


key: 'usedCMIDs',

value: JSON.stringify(usedCMIDs),

ttl: 18000

var usedCMIDs = JSON.parse(myCache.get({

key: 'usedCMIDs',

ttl: 18000



mcfly Rookie Asked on September 19, 2019 in SuiteScript.

Could you set a custom field in beforeSubmit with whatever you need, and then get the value in afterSubmit?

on September 19, 2019.
Add Comment
2 Answers

I wouldn’t recommend using the cache module for this. The intended use of the module is to improve performance, not as a messaging mechanism between scripts. Notably, whilst you are able to specify a TTL, NetSuite makes no guarantee that the data will not be removed earlier, so even if it works 99% of the time it’s not best practice and can lead to hard to track bugs in the future.

Advanced Answered on September 19, 2019.

Fair enough! So what is your alternative to passing value between BeforeSubmit and AfterSubmit functions of the same script??

edit: nevermind, I found the answer by myself

on September 20, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.