Ask Search:
Barunava PalBarunava Pal 

Need help with Flow!

I have a requirement which I believe can be implemented by Flow. Need your guidance!

I have custom objects Invoice and Invoice Lines (M-D). Invoice is related to Cases by look-up. Invoice Lines can be of different types and one type is simiar to Products. 

My requirement is to create a functionality that will create an order from case. In Case page I want to add a button. A user will click the button. An order (for the same account) will be created. A few order fields will be updated (like I have a custom Order.Case__c field which has to be set as the Case ID of the record).

Then it will go through the Invoice Lines for the Case and create a Order Product for every Invoice Line which has a Product. 

So my desired outcome is at one button click an order with relevant order products will be created. 

Is this implementable by Flow? Is it possible to create this button through quick action linked to this flow?
Best Answer chosen by Barunava Pal
Tim Johnson-ReynoldsTim Johnson-Reynolds
your starting point would be to create the recordId variable and lookup the initiating object 
You'll need a fast lookup to look up related invoiced lines.

Loop through these to create your order product lines in an sobject collection variable

finally a fast create to create the order product lines from the sobject collection variable

Maybe something like this Trailhead project will prepare you to tackle this:

https://trailhead.salesforce.com/en/projects/flow_reassign
 

All Answers

Tim Johnson-ReynoldsTim Johnson-Reynolds
Hi

This is totally possible with flow as is triggering from an Acton. Although with an action you need to create a variable called recordId so the Id on the record you are on will be passed to the flow, this is your starting point. 

I'd highly recommend getting on trail head and doing the module on flows

https://trailhead.salesforce.com/en/modules/business_process_automation
Barunava PalBarunava Pal
Tim,
I've completed this module before and in fact I revisited this one and followed the steps from the example (cloning opportunity and products) while creating my flow. My issue was that I didn't want to use process builder to start the process and create the order. Can a flow work independently and complete what all I want and can be invoked by a button click?
Barunava PalBarunava Pal
Thanks, can you guide me about how should I start the flow? What I mean is how should I create the order in the flow with some values from the case?
Tim Johnson-ReynoldsTim Johnson-Reynolds
You can create the action by going into object manager - > select the object - > Buttons,Links, and Actions - > New Action

User-added image

Select Flow as the action type
select the flow
give a label and name

User-added image
Then add it to the layout

Obviously the flow must exist and be active first. In the flow ensure you add the following variable


User-added image

This will give you the current record ID which is probably going to be your starting point. 
Barunava PalBarunava Pal
Thanks for all your helps here but I'm getting into a chicken and egg kind of situation here. I need to create a flow and activate it in order to call it from a Quick Action. Now if I start creating a flow, what is the first thing I should do? Create a variable to store the Case ID from the record page I am calling the flow?

Is there an exhaustive user guide / help article on flows? Looks like it has immense potential but unfortunately help resources are insufficient! 
Tim Johnson-ReynoldsTim Johnson-Reynolds
your starting point would be to create the recordId variable and lookup the initiating object 
You'll need a fast lookup to look up related invoiced lines.

Loop through these to create your order product lines in an sobject collection variable

finally a fast create to create the order product lines from the sobject collection variable

Maybe something like this Trailhead project will prepare you to tackle this:

https://trailhead.salesforce.com/en/projects/flow_reassign
 
This was selected as the best answer