Problem copy nodes with link

Hi,
I have a problem when I copy nodes and link.
The json string have two links with same id.
Link with id “idLink”:“4509” is duplicated:

“class”: “go.GraphLinksModel”,
“linkFromPortIdProperty”: “fromPort”,
“linkToPortIdProperty”: “toPort”,
“modelData”: {“position”:"-33.5 -11"},
“nodeDataArray”: [
{“category”:“activity0”, “item”:“generic task”, “key”:“1_195”, “loc”:“392.5 30”, “text”:“MAN 0”, “taskType”:0, “cod”:"", “idDiagramma”:“0”, “idMansione”:“195”},
{“category”:“activity1”, “item”:“generic task”, “key”:“2_196”, “loc”:“272.5 120”, “text”:“MAN 1”, “taskType”:0, “cod”:"", “idDiagramma”:“0”, “idMansione”:“196”},
{“category”:“activity3”, “item”:“generic task”, “key”:“3_197”, “loc”:“122.5 270”, “text”:“MAN 2”, “taskType”:0, “idDiagramma”:“0”, “idMansione”:“197”},
{“category”:“activity4”, “item”:“generic task”, “key”:“4_198”, “loc”:“32.5 390”, “text”:“MAN 3”, “taskType”:0, “idDiagramma”:“0”, “idMansione”:“198”},
{“category”:“activity1”, “item”:“generic task”, “key”:“2_201”, “loc”:“512.5 120”, “text”:“MAN 1”, “taskType”:0, “idDiagramma”:“713”, “idMansione”:“201”, “textColor”:“red”},
{“category”:“activity1”, “item”:“generic task”, “key”:“2_207”, “loc”:“398.82000732421875 227.5”, “text”:“MAN1”, “taskType”:0, “idDiagramma”:“0”, “idMansione”:“207”},
{“category”:“activity1”, “item”:“generic task”, “key”:“2_208”, “loc”:“71.82000732421875 551.5”, “text”:“MAN1”, “taskType”:0, “idDiagramma”:“0”, “idMansione”:“208”},
{“category”:“activity1”, “item”:“generic task”, “key”:“2_2082”, “loc”:“460 530”, “text”:“MAN1”, “taskType”:0, “boundaryEventArray”:[]},
{“category”:“activity4”, “item”:“generic task”, “key”:“4_1982”, “loc”:“770 340”, “text”:“MAN 3”, “taskType”:0, “boundaryEventArray”:[]}
],
“linkDataArray”: [
{“from”:“1_195”, “to”:“2_196”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“2666”, “points”:[392.5,66,392.5,76,392.5,76,324,76,324,68,272.5,68,272.5,64,272.5,84], “lflFrom”:“1”, “lflTo”:“3”},
{“from”:“2_196”, “to”:“3_197”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“2667”, “points”:[272.5,156,272.5,166,272.5,190,122.5,190,122.5,214,122.5,234], “lflFrom”:“4”, “lflTo”:“6”},
{“from”:“3_197”, “to”:“4_198”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“2668”, “points”:[122.5,306,122.5,316,122.5,325,32.5,325,32.5,334,32.5,354], “lflFrom”:“7”, “lflTo”:“9”},
{“from”:“1_195”, “to”:“2_207”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“4508”, “points”:[392.5,66,392.5,76,392.5,123.75,398.82000732,123.75,398.82000732,171.5,398.82000732,191.5], “lflFrom”:“1”, “lflTo”:“20”},
{“from”:“4_198”, “to”:“2_208”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“4509”, “points”:[32.5,426,32.5,436,32.5,465.75,71.82000732,465.75,71.82000732,495.5,71.82000732,515.5], “lflFrom”:“10”, “lflTo”:“26”},
{“from”:“4_1982”, “to”:“2_2082”, “fromPort”:“B”, “toPort”:“T”, “idLink”:“4509”, “points”:[770,376,770,386,770,430,460,430,460,474,460,494], “lflFrom”:“10”, “lflTo”:“26”}
]}

How can i solve this problem?

Sincerely

Are you using GoJS 1.6 beta? It is only recently with version 1.6 beta that there is a GraphLinksModel.linkKeyProperty, but you do not seem to be using that, because I do not see that property set in the JSON text.

That tells me that you are implementing the “idLink” property on your data.

Hi,
I don’t use 1.6 beta because I prefer wait release version. My software was installed at two clients.
When release version will be available?

Thanks
Giuseppe

It shouldn’t be too long from now. But definitely not this week.

But if you don’t try it now, you won’t be able to influence the design and implementation of that functionality. How will you know if it works for you unless you try it?

Also, don’t you need to fix the bug in your code that is maintaining that “idLink” property on your link data objects? Maybe this new 1.6 feature will do that for you, after only minor customizations.

Hi Walter,
I solved the problem. I used version 1.6.5 and I developed this code:

myDiagram.model.linkKeyProperty = “idLink”;
// link data id’s are even numbers
myDiagram.model.makeUniqueLinkKeyFunction = function (model, data) {
var i = model.linkDataArray.length * 2 + 2;
while (model.findLinkDataForKey(i) !== null) i += 2;
data.idLink = i; // assume GraphLinksModel.linkKeyProperty === “id”
return i;
};

Thanks
Giuseppe

Actually you do not need to set data-idLink = i; – whatever value is returned is assigned as the key for that data, so it will do that for you.

That way your code does not need to hard-code the name of the link key property.