How to insertLink custom data for link while drawing link

Hi… All

I am trying to insert Custom Link data while drawing Link.
By using linkingTool.insert(fromnode, fromport, tonode, toport) but getting error
i.e.
go.js:13 Uncaught Error: Diagram.select:part value is not an instance of Part: [object Object]
at Object.k (go.js:13)
at Object.Cd (go.js:15)
at Object.A (go.js:14)
at E.select.E.select (go.js:808)
at wi.doMouseUp (go.js:550)
at E.doMouseUp (go.js:725)
at a.qp (go.js:932)

And my code is

var tool = myDiagramModalInputTable.toolManager.linkingTool;
tool.insertLink = function (fromnode, fromport, tonode, toport) {

    var newLink = {
        
    };

   //**Which Object could be return???**
    **return {from: fromnode.data.key, to: tonode.data.key}**;
}

if I am missing anything please help me

The simplest solution is to just set LinkingTool.archetypeLinkData to be a JavaScript Object with whatever properties you like.

Each call to LinkingTool.insertLink will make a copy of that object as the model data for the new Link.

If you want to customize the data depending on the circumstances of the new link-drawing, implement a “LinkDrawn” DiagramEvent listener that sets whatever properties you like on the e.subject.data.

Remember that if the Link has data Bindings whose sources are data properties that you want to set, you’ll need to call Model.setDataProperty.