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
Nicholas ZuaroNicholas Zuaro 

convert flow to apex

Hello,
I have heard that a Visual Work Flow is simply just giving a user friendly interface to APEX, right?
Well, in one of my flows that has a few loops in it, and must loop through over 1,000 records I happen to surpass the 2,000 executable elements per flow limitation. 
With this being said, I'd like to create the corresponding APEX for the actions that my flow goes through. If I could achieve what I'm trying to do via APEX since there wouldn't be any flow limitations, that would be perfect!
 

Only problem, is that I know little to none about writing APEX, so I was actually also hoping to use this as a learning opportunity.
But I can't find any documentation regarding what corresponds to what.
Like for example, 
"In a flow, you have a fast-create, in APEX, to achieve the same functionality you have to write in '.......' to achieve '......', and so on and so forth", etc.
Since I enjoy creating flows, I think looking at APEX from this perspective would greatly help me learn APEX because I have functionality to compare it to from flows.

I don't know if anyone knows anywhere that I can find some type of directory or other source of information similar to what I'm describing.

Here's the aforementioned flow that I was having an issue with. It was simpler at one point, but I had (once again) hit a flow limitation. A Fast Create can only create 200 records at once. So since that's the case, I had to route the flow back to the beginning so that it can use that Fast Create 5 or 6 times in order to create all 1,000 records. Obviously now that that's laid out for you, you can see that that's clearly going to blow right past the 2,000 executable elements limitation.
User-added image

Andy BoettcherAndy Boettcher
So yes and no.

No:  TECHNICALLY, VWF is NOT Apex, nor is it a user interface for Apex outside of passing data to/from InvocableMethods.

Yes:  Thought-wise (using "if this then that" thought processes) Apex is similar.  There are still limits that Apex has, but there are additional things like Batching that allows you to chunk things up to work around limits.

What is your true question?  Are you looking for someone to write an Apex version of your Flow?
Nicholas ZuaroNicholas Zuaro
Well dreams don't always come true so I'm not so I wouldn't expect anyone to ever want to do that for me. I'm happy to do it myself but I'm extremely new to APEX. I'm eager to learn and was hoping that comparing my flow to the corresponding type of action in APEX would be a good way to learn how to achieve certain goals.
My TRUE question was basically if anyone could provide me with some type of documentation pointing me in the right direction of some sort of comparison like I mentioned earlier.
Anything that I find regarding APEX is showing how to build classes and controllers and triggers but I was hoping for something more specifically showing me how to achieve different functions.
Like how to loop through a specific set of records, how to pull out which data and assign that data to new fields in a different object and "fast" create several hundred more records, etc. etc.
But I'm also not necessarily hoping to limit what type of response I might get based on that answer... if you have any suggestions for how i can achieve my desired functionality i'd be happy to try anything out! I'm pretty much backed into a corner at this point..
Andy BoettcherAndy Boettcher
Great answer Nicholas - "I want to learn".  =)

The BEST thing I can point you at to get started is Trailhead.  Go through the Beginner Developer Trail to get your feet wet, and then we can take it from there.  =)

https://developer.salesforce.com/trailhead

Also - look in your area for your local Developer Group.  That's a great resource as well!  https://developer.salesforce.com/dugs?title=page/Force.com_User_Groups
Nicholas ZuaroNicholas Zuaro
Thank you, sir! You aren't the first to recommend TrailHead so I guess that's really where I should be heading and then perhaps the rest will fall into place as I get further and further.
Well thanks again!
Andy BoettcherAndy Boettcher
Be patient and work the modules - with a little Googling and asking questions here you should be able to convert your existing Flow over to Apex.  Once you get there, then we can get fancy with the Batching part to handle the larger volumes.  =)