Posted: April 25, 2023 at 12:04 pm
I am using and I have this section of code that copies people to the new event. That copying to the new event works, but the original event loses those people! I feel like this was working in the past, but have now noticed it is not. It’s possible that my duplication code was always erasing the people from the original event but I never noticed until now. Additionally, I must have a poor understanding about the way the related tables are handled because duplicating an event should never change the original event, and yet my code below is doing that. How should I fix this so that it correctly copies the people assigned to the new event and leaves the original event intact.
Thanks in advance for any help! |
|
Hi Daniel, Can you post the full snippet you are using for this, please? I’ll test this locally but I want to test the exact code you are using to confirm this. |
|
Sure…
|
|
Hmm, I’m pretty sure you’re basically updating the relation with that code.
That’s pulling the relationships between ‘people’ and the event, NOT the people themselves, so then adding a relation to a relation updates the relation. I’ll check in with our developers on this, may take a little. |
|
So, it’s kind of stealing the related record? I’d love it if you could provide me some sample code that will create the correct relationships! |
|
Basically, yeah. Each ‘Person_Post’ is basically:
So your looping over the relationships and saying relate those to the new event, which will update it to be:
Where 5555 in this example is the ID of the new event.
Thinking on this a little 😉 Right now it’s basically, ‘gimme the relationships for people on {original_event}, update those for {new_event}’ What you need is ‘gimme the people related to {original_event} and create NEW relationships for {new_event}’ Your original query doesn’t need to know about the relationships, just the people as those what you need to relate to the new event. |
|
So, where can I find syntax for creating a new Person_Post? |
|
As mentioned, I’ve asked for some feedback from our developers on this so will let you know once they’ve replied. |
|
I think I got it – this seems to work to create the new related record and doesn’t steal the existing one.
|
|
Edit: should be ‘Event’ not ‘EE_Event’ |
|
The support post ‘Duplicate event issue with copying People Admin people’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.