Catching key/ newly created node via transaction

consider the code in fig

i want to catch the node that is newly created particularly the key as it is auto assigned by the api. How will i do that cz i want to be inside the loop preferably while doing that.?

First, just as with any database programming, you really should not be performing a transaction within a loop.

Second, you can just look at the key on the data after calling Model.addNodeData:

myDiagram.startTransaction(...);
for (...) {
  var data = { ... };
  myDiagram.model.addNodeData(data);
  // now can look at data.key, or more generally:
  var key = myDiagram.model.getKeyForNodeData(data);
}
myDiagram.commitTransaction(...);

in var data can i give partial node data like
{“text”:test, “category”:“fk”,“group”:to1, “not_null”:0};
will it give me the required key?

What happens when you try it?

thanx alot can you help me on my other problem too that self linking one

will be greatful