Changing fromMaxLinks programatically

My application has settings that specify how many links out of a node are allowed for a given node.

My code for modifying the possible number of links out looks like this:

goDiagram.startTransaction(); goDiagram.findNodeForKey(updatedNode.key).fromMaxLinks = updatedNode.numOfPaths goDiagram.commitTransaction();

Ultimately, this code doesn’t seem to change the number of links allowed; the number of links remains at the amount that was originally specified in the Node template.

Is this the proper way to do this? Or am I missing something?

I suspect that what you are missing is that you are setting that property on the whole Node, not on the port as is needed. This is mentioned in the documentation: GraphObject | GoJS API

If your node template is only using a single port, you could do:

var node = goDiagram.findNodeForKey(updatedNode.key);
if (node !== null) {
  goDiagram.startTransaction();
  node.port.fromMaxLinks = updatedNode.numOfPaths;
  goDiagram.commitTransaction("changed fromMaxLinks");
}

But if your node(s) have more than one port, you’ll need to find it or them either with Node.findPort or by iterating over Node.ports.

My nodes have a single port, so updating node.port.fromMaxLinks works.

Thank you.