Forum Stats

  • 3,815,765 Users
  • 2,259,076 Discussions


Javascript-Derived 'Associated Node' Property, when used in DRG, Nulls generate Errors

MNW Member Posts: 118

Hi all,

I searched the support KB and the forums here and feel confident that this hasn't been asked yet. I have the need for a derived, Associated Node(s) property. I put the 's' in parentheses because I'm fairly sure the property needs to be Local. It's a little difficult to explain the logical requirement, but I'll do my best.


Leaf Nodes should be associated with one another according to their limb parent. The first node (in numeric order) under a parent should map to the last node (in numeric order) under the same parent. All other nodes under the parent (Including the last node) should map to the first node under that parent.

Example structure (Node Name - Property Value):

Hierarchy Alpha   

     Parent A - Null

          Child 1 - Child 3

          Child 2 - Child 1

          Child 3 - Child 1

          Child 4 - Child 1

Current Approach

I'm using a derived Javascript Associated Node property to calculate this. It works perfectly in interactive mode with no errors. Below is the script:

var parentList = [];   parentList = node.Parent.GetChildren("hier");       //return null if member is a limb or if the node is not in the COSTCENTER hierarchy (The same node may be linked in other hierarchies and these should have null values)   if (!node.Leaf || !node.PropValue("Custom.EXP_CC") || !(node.Hier.Abbrev=="COSTCENTER")) {      return null;   }   //Splice all limbs from the array and any Cost Centers that shouldn't be exported or considered for mapping   for (x=0;x<parentList.length;) {       if(!parentList[x].Leaf || !parentList[x].PropValue("Custom.EXP_CC")) { parentList.splice(x,1);       } else { x++;       }   }   //If the nodes aren't in numerical order under the same parent, order them numerically   parentList.sort();   //If the first child of the parent, return the parent's last child. Otherwise, return the parent's first child   if (node.Abbrev==parentList[0].Abbrev) {      return parentList[parentList.length-1].Abbrev;   } else {      return parentList[0].Abbrev;   }


This works well in interactive mode. But when used in a DRG workflow, there's a problem. In the case that the node is changed from "EXP_CC==TRUE" to "EXP_CC==FALSE", the property logic returns null, which triggers an error that says "TypeError: Can't convert Undefined, Null or CLR to Object". What I think is happening is that the Associated Node property is returning the value of "Null", which isn't a valid node. In interactive mode this isn't a problem because when you change the Export value from True to False, the Calculated value isn't considered an override.

In DRG, however, I think all updated property values (Including calculated properties) are considered overrides and you can't override an Associated Node value with a null value.

I'd love some guidance on this. I know it's a really specific situation but I think the basic question is: How, in DRG, can I pass a null value to an Associated Node property using Javascript?

Thanks for taking a look!


This discussion has been closed.