I have created a diagram and define a groupTemplate and have a function to update the graph Direction and the fromSpot toSpot of upcoming/incoming link:
Changing a template does not change any existing Parts.
TreeLayout and LayeredDigraphLayout are directional, so they automatically set the Link.fromSpot and Link.toSpot unless you explicitly disable that behavior. Which Layout are you using?
If you are not setting or binding fromSpot and toSpot, then your Orthogonal links should route as you would expect. For example, see Layered Digraph Layout, which allows the user to change the direction of the layout dynamically by clicking on the radio buttons.
But perhaps I misunderstood: you should be setting LayeredDigraphLayout.setsPortSpots to true, if that is what you want.
And I just thought of another possibility: you have set or bound Link.adjusting to some value. Try it without setting that property.
What is your link template?
Precisely which version of the go.js or go-debug.js library are you using?
Are those nodes actually instances of Groups? Are they all collapsed? I do not see how groups are involved.
Setting Link.fromPortId and Link.toPortId is suspicious but not necessarily wrong. It depends on what your group template is, what your node template is, and whether the links are connecting with the member nodes of the groups or with the groups directly. It’s hard to tell with incomplete information.
p1 is not part of the GoJS API, so you should not be setting that on any GraphObject.
That Shape is not a port because you haven’t set GraphObject.portId to a string, so I don’t know how that piece of your group template helps us understand what is going on. It would be much clearer if you defined your templates using a single expression of nested calls to go.GraphObject.make, because then it is easier to understand the visual structure of your group or node or link.