0

I'm going crazy with this flow.

I have a Custom Object named Ri_Event__c with a lookup field to the Opportunity Object. Ri_Event__c also has a custom checkbox field named Completed__c.

I'm trying to create a flow that changes the Opportunity StageName to Closed Won when all the related Ri Events are marked as completed.

The flow is being executed after insert:

enter image description here

enter image description here

enter image description here

enter image description here

After getting the records and storing them in a Collection Variable called RiEventsCollection I'm looping them , checking if the Completed__c field equals true and then I would finally update the related Opp.

I have created an Opp with 3 related Ri Events to it. Two of them are already completed and the third one I'm updating it from the flow debugger to be checked.

enter image description here

This is the result of the debug:

enter image description here

I've tried MANY ways of doing this flow. First I tried retriving the related Opp of the Ri event triggering the flow, them from the related Opp the related Ri Events for THAT Opportunity but it wouldn't let me. So I tried getting the related Ri events from the related Opportunity from the Event triggering the flow, but it wasn't working as expected too.

2 Answers 2

1

You can use the opposite way by querying all the RI_Events whose completed__c is false. If that is null you can update status of opportunity to "Closed Won" as below .

we have "When no records are returned, set specified variables to null" check box turn that to true so that if no records are returned it returns null.

enter image description here

We can use that variable above to check null and then update the opportunity stage.

enter image description here

In this way we are checking if no RI_Events related to opportunity has checkbox as false then we can update the status of opportunity.

10
  • Hey SaiPraveen! Thanks for your reply. I cannot understand the logic here sience I want to update the Opportunity to closed won when all the ri events are Completed, not the opposite. Why would I do it the opposite way ? Cannot understand the logic here. My problem is that when I update the last Event to be completed from the debugger, the other two are still marked as completed but this third one is the one failling the flow and still not marked as completed. Cannot undestand why this is happening either. Feb 28 at 16:34
  • 1
    @NachoZveDeLaTorre, We are not doing opposite. Instead of getting all RI events and looping them and checking Completed__c field I have queried RI events whose Completed__c is false and stored them in a variable . If that variable is null which means there are no RI events with Completed__c as False which means all are True then we can update oppy stagename Mar 1 at 2:52
  • Sai! Thanks for the answer and help again. I do know one of the records is marked as completed = false since in this case there are only 3 events and two of them where completed by myself and the third one is causing the flow to fail. My question is ... I cannot undestand why this is happening. In the debuger I'm causing the flow to fire when a Ri Event is updated and the only change is Completed going from false to true since I'm checking the checkbox. That should make the flow update the Opp at the end, but it is ending in the END from the condition. Mar 1 at 7:17
  • I believe that if I do what you suggest I will still get the last record as completed = false, but I will try it and let you know. Thanks a lot! Mar 1 at 7:19
  • Indeed. I've tried this way as well but still failing. I cannot undestand what's wrong with it. Mar 1 at 8:04
0

You can create a variable to count the number of Events with 'completed' status and increment it each time the status is 'Completed'. Also you can create a overall counter that will increment for each Event irrespective of Status. Both of this can be done in the FOR loop.

Next, you can do an assignment to the Opportunity stagename field with a precondition that closedEventsCounter == allEventsCounter. This can be done in the assignment element after the end of your FOR loop.

1
  • Thanks for the answer. I know I can do that, but it's really not answering my question. I want to know why with the logic I already have the last Event is not being marked as updated when I debug it from the Flow debugger to be updated and the Completed checkox is marked as checked, the flow is STILL failling in this record and marking it as not Completed. Feb 28 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.