Make link unique in flowchart sample

Hi, I’m testing on this sample.

How can I make the link unique and not duplicated?

I’ve tried to set toLinkableDuplicates and fromLinkableDuplicates to false in makeport function but it doesn’t work.

Which link are you talking about being “unique and not duplicated”?

toLinkableDuplicates and fromLinkableDuplicates have default values of false, so setting those to false won’t make any difference. So by default the user cannot draw duplicate links.

See GoJS Validation -- Northwoods Software for more discussion of limiting what links the user can draw or reconnect.

HI walter, from the sample, I could connect 2 ‘Step’ node in this way.

image

I want to achieve something like this, and restrict any more linkage from step 1 to step 2.
image

I’ve added a link validation in my link and it works perfectly.

  uniqueLink(fromnode, fromport, tonode, toport) {
    const linksOut = new go.List().addAll(fromnode.findLinksOutOf()).iterator;
    while (linksOut.next()) {
      if (fromnode.data.key === linksOut.value['data'].from && tonode.data.key === linksOut.value['data'].to) {
        return false;
      }
    }
    return true;
  }

I think you could write that more concisely as:

return fromnode.findLinksOutOf().all(function(link) {
    return link.toNode !== tonode;
});