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
Tasia Demuth 4Tasia Demuth 4 

Can you call a flow from a List button for an opportunity product

Is it possible to
1.create a list button on the related list for opportunity products 
2.call a flow from that list button. 

This is the visualforce page I constructed, but it says that List Controllers are not supported for OpportunityLineItem. If this is the case, is there any way around this, where I could have a list button that allows me to take action on multiple opportunity line items from within the opportunity?

<apex:page standardController="OpportunityLineItem" lightningStylesheets="true" tabStyle="OpportunityLineItem" recordSetVar="AllOpportunityLineItems">
  <apex:repeat value="{!AllOpportunityLineItems}" var="row" rendered="false">
  {!row.id}
  </apex:repeat>
  <flow:interview name="Opp_close_lose"
  finishLocation="{!URLFOR($Action.OpportunityLineItem.Tab, $ObjectType.OpportunityLineItem)}">
  <apex:param name="recordId" value="{!Selected}"/>
  </flow:interview>
</apex:page>

Let me know and thank you in advance for your help!

Tasia
Best Answer chosen by Tasia Demuth 4
Alain CabonAlain Cabon
Hi,

It is impossible to use recordSetVar with OpportunityLineItem so you cannot create the button to choose the products for your flow directly with the standard related list of products.

The products have to be selected in your flow with a dynamic choice or with a new VFP.
The button that launchs the flow Opp_close_lose is on the opportunity (parent object).

Adding and Configuring a Dynamic Choice:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_implementation_guide.meta/salesforce_vpm_implementation_guide/vpm_designer_elements_screen_dynchoice.htm

Using a dynamic choice to select multiple records in visual workflow:
https://goravseth.com/using-a-dynamic-choice-to-select-multiple-records-in-visual-workflow


User-added image
 

All Answers

Alain CabonAlain Cabon
Hi,

It is impossible to use recordSetVar with OpportunityLineItem so you cannot create the button to choose the products for your flow directly with the standard related list of products.

The products have to be selected in your flow with a dynamic choice or with a new VFP.
The button that launchs the flow Opp_close_lose is on the opportunity (parent object).

Adding and Configuring a Dynamic Choice:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_implementation_guide.meta/salesforce_vpm_implementation_guide/vpm_designer_elements_screen_dynchoice.htm

Using a dynamic choice to select multiple records in visual workflow:
https://goravseth.com/using-a-dynamic-choice-to-select-multiple-records-in-visual-workflow


User-added image
 
This was selected as the best answer
Alain CabonAlain Cabon
From the list of products attached to the opportunity OpportunityLineItem, the last option is a javascript button (not recommended if you want to migrate to lightning) and that could be more complicated than the dynamic choice from the opportunity.

If someone has this solution with a javascript button, that could be very interesting for your problem.

https://developer.salesforce.com/forums/?id=906F000000091pGIAQ

The call of the flow itself is easy in javascript but you need to pass the selected products (Ids) .That is the problem.
Probably possible but that is not a recommended solution anymore (that will never work in Lightning if it is a javascript button).
Tasia Demuth 4Tasia Demuth 4
Thank you, Alain! 

The dynamic choice is working so far. I tested it as a button on the opportunity and will now write the code for the list button. 

Thanks again!
Tasia
Alain CabonAlain Cabon
Hi Tasia,

I was ready to help you for the next steps (that was just the principle) but you are stronger than I myself in building sophisticated solutions with flows. Your questions are not easy and diverse. You help me to make progress too (as far as I can, I remember my failure for your question on analytics. I passed a superbadge Einstein Analytics Data Preparation Specialist that would have helped me at that time for your problem, very rare questions on analytics here excepted yours).

Thank you very much for your feedback and congratulations for your flow (certainly very fine).
 
Best regards
Alain
Tasia Demuth 4Tasia Demuth 4
Thank you, Alain! I appreciate that!! I look forward to working with you on interesting problems in the future. Tasia Tasia DeMuth Business Applications Administrator Tel 303-345-9125 Cell 720-224-8036 Fax 303-484-4279 tasia_demuth@esource.com www.esource.com