Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Formula Builder patch

    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?


    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
    		}
    		
    
    	})

    #2
    Hmm, it also appears that invalid field reference below of

    J:\"formulaFie ld4\"

    is causing the formula to not fire successfully. I have to re-save the formula in order for it to work. So, there must be some other patch needed so that the formula correctly fires in this case. Are you able to investigate that?

    Comment


      #3
      fyi, the space is not valid. It should look like this. That was my mistake when pasting the contents....

      J:\"formulaField4\"

      Comment


        #4
        We've made a few changes (to 8.2p) that should address all of these issues - please retest with a nightly of October 28 or later.

        Comment


          #5
          Looks better. Is it safe to assume this change will be present in 8.3 going forward too?

          Although improved, it is still not successfully firing the formula when it should be.


          Here is the formula state again:
          {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}


          Variable J is not part of the actual formula. The only two variables that are part of the formula are EJ and A. So, even though J and E are listed in the formulaVars object, is it possible to ignore the fact they are not valid fields and to let the formula still fire in this case?

          Here is the message I am seeing

          13:40:29.141:TMR3:WARN:Log:Field formulaField4 is not in the list of available-fields
          13:40:29.141:TMR3:WARN:FormulaBuilder:Formula failed due to missing fields: formulaField4.

          Comment


            #6
            We've made some further changes in this area - fields that appear in formulaVars but not in the actual formula-text will now be ignored and a warning logged. All recent changes in this area will appear in all branches from 1st November.

            Comment


              #7
              Works great, thanks.

              Comment

              Working...
              X