RE: What is the best method of passing values from BeforeSubmit to AfterSubmit portion of a User Event Script.
Hi,
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 https://netsuite.custhelp.com/app/answers/detail/a_id/23967/kw/cash%20sale%20credit%20memo to apply a Credit Memo to a Cash Sale before Credit Card gateway process.
var myCache = cache.getCache({ name: 'temporaryCache', scope: cache.Scope.PRIVATE }); myCache.put({ key: 'usedCMIDs', value: JSON.stringify(usedCMIDs), ttl: 18000 }); var usedCMIDs = JSON.parse(myCache.get({ key: 'usedCMIDs', ttl: 18000 }));
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.
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
mreser
Could you set a custom field in beforeSubmit with whatever you need, and then get the value in afterSubmit?