In SS1 I remember declaring global variable outside of entry points (e.g pageinit, fieldchanged, saverecord) - with these variables and functions I used to process common business logic and then use the values across all entry points. E.G. Calculate and declare summarized value and keep it stored in a variable, then can use this variable in pageinit or saverecord or fieldchanged - this was useful to have common variables and calculations done and populated.
With SS2 however am unable to do this as we do not have objects like scriptContext etc. available outside of entrypoints, thus unable to create global variables.
This seems a very basic need and was readily available in SS1. Am I missing something ?
E.g. var own = scriptContext.newRecord.getValue({fieldId : "owner"});
var emp = scriptContext.newRecord.getValue({fieldId : "custrecord_hc_trn_part_emp"});
var same = false;
if (own == emp){same = true;}
This code can run in beforesubmit or aftersubmit as the scriptContext object is avialble to these entry points. However If I call these outside of any entry points the scriptContext object does not exist.
Basically I would like to get these values and use it across all entry points. In my example I need to identify if the employee and the record creator are same and use this in all functions so that I dont have comare everytime.
Another example is dosomething then in beforesubmit dosomethingelse and then use the same in aftersubmit. is there a way we can pass values across entrypoints and also without any entrypoints.
Does anyone have any workaround ? Any suggestions to accomplish this ?