function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Itay MaozItay Maoz 

Changing relatedto from account to opp when Contact role added

I'm trying to relate all tasks from an account to an opportunity when a contact is added as a contact role to the opportunity. There are 3 elements:

1. Passagetech rollup/lookup that populates most recent opp on a contact when they are added as a contact role on an opp
2. Process builder that kicks off flow when that field is updated
3. Flow to loop through tasks on contact and change whatid from account to opportunity for all tasks that were created after the opportunity create date.


It's worked a few times in sandbox, but in production I am getting this error:

Error element update_task_relation_final (FlowRecordCreate).
This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: You can only add up to one what relation.: Task ID. 

I'm not sure how to get around this. I thought the loop would be enough to get around this.  Any help would be appreciated.

Thanks!

Here is a screenshot of the flow:

In record create I'm creating a new taskrelation

visual flow add tasks to opp

 
Itay MaozItay Maoz
If there is no explicit solution, Does anyone know where I can go to find a solution? Or are there any sinilar issues?