How to select a link Programatically

How to select a link Programmatically?

For Node we are using
var node = myDiagram.findNodeForKey(key);
myDiagram.select(node);

What will be the syntax for Links?

If you have turned on keys for link data, by setting GraphLinksModel.linkKeyProperty to the name of some property to be set on your link data objects, then you could call GraphLinksModel.findLinkDataForKey to find the link data object, upon which you could call Diagram.findLinkForData.

If your links do not have keys, then you might try calling Diagram.findLinksByExample. Or find a particular Node, as your code does, and then look at the results of calling Node.findLinksConnected or one of the other “findLinks…” methods.

In general there might be multiple links between the same pair of ports. But that might not be the case in your app, so it might be easier for you to choose the desired Link.

We are using

var link = myDiagram.findLinksByExample({“key”:2}).first();
but getting null result.

And you are sure that there is at least one link data object that has the “key” property with value the number 2?
Have you set GraphLinksModel.linkKeyProperty?