Ok, how can I assign an existing relation to a new object using javascript? Are you saying that the new object has to be created first before setting relations to it?
If you move that logic into afterCreate, you should be able to establish a relation between Notification and Category there using the add/setRelation API.
That will not work, since I won’t know which Category to relate the Notification to. In the before trigger, I was able to get the item.category.channel to get the correct Category.
The after trigger, I will not have that information any more, therefore, I won’t know which Category to get.
That’s not a problem. Backendless provides a way to pass data from the “before” to the “after” handler. We call it “crossHandlerData”. Here’s how you could use it in JS business logic: