Need to call a function before LinkDrawn

Hey Walter, is there any event in GOJS which is triggered before LinkDrawn?

The requirement is while I am dragging the linking tool, and just before LinkDrawn is triggered, I need to call a custom function which does some validation and if it returns false, I don’t want the link to be drawn.

You can do that in the “LinkDrawn” DiagramEvent listener. For example, to prevent links drawn from “red” nodes to “green” nodes:

  new go.Diagram("myDiagramDiv",
    {
      "LinkDrawn": e => {
        const link = e.subject;
        if (link.fromNode.data.text.indexOf("red") >=0 &&
            link.toNode.data.text.indexOf("green") >= 0) {
          e.diagram.currentTool.doCancel();
          alert("disallowed")
        }
      },
      . . .

the custom function i am calling is expecting the current GOJSModel as a parameter and in that model the link is already created in the linkdataarray which causes an issue.

Maybe you can use general link validation, described in the validation intro page here.