Have the following code in a function node. Function node fed by a join node that's fed with a Drop Down select and a table.
I'm looking for table values that are undefined or null so that I can use a previously entered value so user doesn't have to re-enter unchanging variables. However, it just doesn't work. I don't get an error out of the function node. The function node doesn't seem to be processing the global.get("var["+element_number+"].payload.variable. That being said, I'm trying to assign an incoming payload to the element number variable.
var binNo = msg.payload.Bin;
var binDiam = msg.payload.BinDims.DiamFt;
var binRings = msg.payload.BinDims.Rings;
var binRingHeight = msg.payload.BinDims.RingHeightIn;
var binFloorGap = msg.payload.BinDims.FloorGap;
var binDiamFile = global.get("BinDims["+binNo+"].payload.DiamFt","file");
var binRingsFile = global.get("BinDims["+binNo+"].payload.Rings","file");
var binRingHeightFile = global.get("BinDims["+binNo+"].payload.RingHeightIn","file");
var binFloorGapFile = global.get("BinDims["+binNo+"].payload.FloorGap","file");
var PI = 3.1415926535;
var binBushels = 0;
var binRHFeet = 0;
var binFGFeet = 0;
var binHeightToEave = 0;
var binConeVolume = 0;
var msg1 = {};
if (typeof binDiam === 'undefined' || binDiam === null){
binDiam = binDiamFile;
}
if (typeof binRings === 'undefined' || binDiam === null){
binRings = binRingsFile;
}
if (typeof binRingHeight === 'undefined' || binDiam === null){
binRingHeight = binRingHeightFile;
}
if (typeof binFloorGap === 'undefined' || binDiam === null){
binFloorGap = binFloorGapFile;
}
binRHFeet = binRingHeight / 12;
binFGFeet = binFloorGap / 12;
binHeightToEave = ((binRHFeet * binRings) - binFGFeet);
binBushels = ((PI*(binDiam/2)*(binDiam/2))*binHeightToEave);
binConeVolume = PI * (binDiam/2) * (binDiam/2) *((0.4244748162*(binDiam/2))/3);
binBushels = binBushels+binConeVolume;
binBushels = binBushels * 0.7783750000;
binBushels = Math.round(binBushels*1)/1;
msg1.payload = {DiamFt:binDiam, Rings:binRings,
RingHeightIn:binRingHeight, FloorGap:binFloorGap, CalcVolume:binBushels};
global.set("BinDim["+binNo+"]",msg1,"file");
return msg1;
The point of this flow to allow user to update any changing parameters, re-calculate the pertinent values and refresh the tab. When I enter data into ALL of the fields in the table, it functions properly.
Any suggestions?