Link - Receive another value at source and target

Hello,
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

Hello,
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:
https://snippet.dhtmlx.com/da4af1440

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:
http://snippet.dhtmlx.com/8061689e0

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.

Hello,
You can obtain the link object with the target and source properties from the link variable:
https://docs.dhtmlx.com/gantt/api__gantt_onbeforelinkadd_event.html
Or by using the gantt.getLink(id) command:
https://docs.dhtmlx.com/gantt/api__gantt_getlink.html

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

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

https://docs.dhtmlx.com/gantt/api__gantt_gettask.html
https://docs.dhtmlx.com/gantt/desktop__link_object_operations.html