Whats your approach/tips to achieve this: Don't h...
# general
e
Whats your approach/tips to achieve this: Don't have too many scripts polluting a record AND Don't hit governance limits if consolidating scripts
a
The way I look at this: • Too many scripts polluting a record could be relative and debatable. • Hitting governance limits is a real problem that disrupts functionality. So, I would try to polish the polluting scripts and carefully merge the ones that make sense merging.
1
b
consolidate all the scripts, toss any that consume too many points into a scheduled script or map/reduce script
a
@Edgar Valdes At the end you also need to consider your branching strategy or how your repo is structured etc, if you work with a team or this will be maintained by a single developer. Consolidating everything into a single script brings its own challenges if you are working with a team and multiple developers needs to update/modify the same file at the same time etc...
b
i heavily recommend not actually consolidating the actual script files, you want to keep those separate. If you are getting into actual implementation details, the lazy way is to make a new script that calls the old script files, the copy pasted version looking like
Copy code
function beforeSubmit(context) {
  userEventModule1(context);
  userEventModule2(context);
}
with you userEventModule1 being the user event script files being used as custom modules
1
you would probably want to do much better error handling than what is shown, with an actual looping mechanism
j
A modular framework is absolutely the way to go with consolidation.