Hi Sidhant,
It is not possible to add this data in the error message of a delete prevention action of an association. You would rather solve this by either adding this message in the delete button action on the page, or by adding a before delete event handler to the TrainingEvent object. There, you can use a MF to create an error message for the user who is trying to delete the TrainingEvent. Please bear in mind that with this association you can have multiple registrations and so multiple trainees associated to this trainingevent, so that means that you would have to take this into account in your Microflow logic aswell.
I was able to resolve the above issue by using a microflow. I invoked a microflow (from the Training Event page) through Delete button. In the microflow, the first step was to get the registration entity and TrainingEvent information for which was done using Retrieve object (retrieved the association Registration_TrainingEvent), the second step is to create a empty string which will be used to store the names of the students enrolled in a course (which will be displayed if try to delete a course with Trainee>0). In the third step I used a for loop to iterate over the RegistrationList which was retrieved from the first step, in the for loop I used another Retrieve entity to get the list of Trainee students in course and used a change variable entity which will append the Trainee name in the empty string (here named as Variable) {Expression $Variable + $Trainee/Name}. Outside the for loop I added a Decision box to check if there are no students enrolled (i.e Variable= ‘ ‘/empty) then delete the object else display the message (using show message).
Microflow:
Expected Result: