Hello,
We had to write a patch for Formula Builder for a recent 8.2 build.
If you look below at the patch, we added a null check on _3.find('name',_8[_9]) which is used to populate the variable _11.
Here is the state of the formula where this error was occurring.
{name:\"formulaField5\",userFormula:{text:\"EJ-A\",formulaVars:{EJ:\"scenarioPT3\",J:\"formulaField4\",E:\"pctChangeDay\",A:\"currentPrice\"}},title:\"$ Chg from Downside Price Target\",width:82,autoFitWidth:true}
It looks like there are two problems. First, the existing logic wasn't accounting for a formula field that gets removed because "formulaField4" as referenced by J above was removed by the user and so no longer a valid field. The null check seems to have fixed that. Second, is it possible that E and J shouldn't have been included as formula vars at all since the actual formula is EJ-A and thus doesn't include E and J as variables?
We had to write a patch for Formula Builder for a recent 8.2 build.
If you look below at the patch, we added a null check on _3.find('name',_8[_9]) which is used to populate the variable _11.
Here is the state of the formula where this error was occurring.
{name:\"formulaField5\",userFormula:{text:\"EJ-A\",formulaVars:{EJ:\"scenarioPT3\",J:\"formulaField4\",E:\"pctChangeDay\",A:\"currentPrice\"}},title:\"$ Chg from Downside Price Target\",width:82,autoFitWidth:true}
It looks like there are two problems. First, the existing logic wasn't accounting for a formula field that gets removed because "formulaField4" as referenced by J above was removed by the user and so no longer a valid field. The null check seems to have fixed that. Second, is it possible that E and J shouldn't have been included as formula vars at all since the actual formula is EJ-A and thus doesn't include E and J as variables?
Code:
isc.FormulaBuilder.addClassProperties({ getAvailableFields:function(_1,_2){ var _3=[],j=0;if(!_1)return _3;for(var i=0;i<_1.getLength();i++){var _6=_1.get(i),_7=_6.type;_6.originalOrder=i;if(_2&&_2.name==_6.name)continue;if(_6.userFormula||isc.SimpleType.inheritsFrom(_7,"integer")||isc.SimpleType.inheritsFrom(_7,"float")) {_6.mappingKey=isc.FormulaBuilder.mappingKeyForIndex(j++);if(!_6.title)_6.title=isc.DataSource.getAutoTitle(_6.name);_3.add(_6)}} var _8=_2&&_2.userFormula?_2.userFormula.formulaVars:{}; for(var _9 in _8){ if(_3.find("mappingKey",_9)!=null && _3.find("name",_8[_9])!=null ){ var _10=_3.find("mappingKey",_9),_11=_3.find("name",_8[_9]),_12=_11.mappingKey;_11.mappingKey=_10.mappingKey;_10.mappingKey=_12 } } _3=_3.sortByProperties(["mappingKey"],[true],[function(_6,_14,_15){var _13=_6[_14];if(_13.length==1)_13=' '+_13;else if(_13.length==2)_13=' '+_13;return _13}]);return _3 } })
Comment