Link - Receive another value at source and target

when i create the link, the source and target come with id task and i need to come with another value. I have 2 primary keys.
Is that possible to receive sourcetask and targettask on event “onBeforeLinkAdd”? Or receive another values on source and target.

Thank you

You can change link parameters in the onBeforeLinkAdd event handler:

But please note that the event is not asynchronous. The parameters should be ready before you start adding a link, otherwise, it won’t work. Here is the snippet:

If you want to obtain the values from the database or somewhere else, you need to wait until the link is added and modify the parameters in the onAfterLinkAdd event handler:

Here is the snippet:

You can check the following topic, you can find the answers to similar questions:

Thank you for you answer.
I need another parameter on event “onBeforeLinkAdd” for example all the object of the source task and the all the object of the target task and not only the id’s.

Is that possible?
Thank you.

You can obtain the link object with the target and source properties from the link variable:
Or by using the gantt.getLink(id) command:

Then you can get the task objects by using the gantt.getTask(id) command:

var target_task = gantt.getTask(
var source_task = gantt.getTask(link.source)