CBD Seed Inventory done right/fast in Salesforce

One of the coolest things about Salesforce is the ability to build really custom solutions without coding an entirely custom software tool for a client.   A new client of Trackland’s brought a really interesting need to us.  Hilo Hemp Seed came to us hoping to get a better CRM solution for tracking their seed through the sales to fulfillment process.  Generally speaking, that’s a slam dunk for Salesforce, and Trackland Sheets makes product management and proposal building with Salesforce data even easier.  The real problem was inventory management.  HiLo sells millions of seeds each year.  Issues arise when proposals and existing orders are both selling the same seeds from the same lot.  Whether the seed from a certain lot was already sold on a number of orders, or promised on different proposals, the guys at HiLo needed a solution that would keep them from selling seed they did not have.

All Hemp Seed Is Not The Same

HiLo Hemp Seed is a top quality hemp seed producer. They primarily focus on providing seeds with a germination rate above 95%.  HiLo currently produces a single family of hemp seed they call Autopilot 1.0.  This seed is grown in different groups they call “lots”.   Even though all of a lots seed is from the same seed family, the seed in one lot can be quite different in size and color from another lot.  Regardless of the shape, size and weight, of the seeds the quality testing is the same. With physical differences between the seeds in lots however, preferences from buyers between lots will exist.
HiLo also sells seeds from other producers such as a Cherrywine seed.  This provides a single source for buyers wanting more than one seed family.  These other varieties of hemp seeds will also come in lots.  I needed to provide a simple yet powerful way to ensure that a proposal was never created that had more seed from a single lot than was available in that lot.

Structuring The Hemp Seed Inventory

The first thing I had to do was determine what Salesforce object I wanted to use to represent the product which was essentially the lot.  We had quantities of see within a lot, but the lot was essentially the “Product”.  A buyer who wanted seed from Lot A would be happy with any of the inventory seed in Lot A.  They might not be happy with a partial substitution of seed from Lot B so the lots would be the product.  By making the lots the Product2 object in Salesforce we get all the baked in CRM features Salesforce provides for proposals and quotes applied to our seed lots.
A second concern was how I would represent the different seed families.  Product2 comes with a picklist/select field for Product Family out of the box.  I could have just added product families to to the picklist and been done.  I wanted to ensure integrity of inventory as far up the chain as possible however.  I explored a parent object to the Product2. It turned out that a parent Product Family object to the native Product2 object was a good idea.  It gave me the ability to add seed count for all of a certain product family.  Now I had a count regulation at the Family level.  HiLo could essentially track that Autopilot 1.0 produced 150 million seeds and purchased 120 million seeds of the Cherrywine variety.  As they added lot/Product2 records referencing these product families, HiLo would have the correct number of seeds across all the lots for that seed family.  This was just one more layer of seed inventory integrity.

Don’t Sell That Guy’s Hemp Seed!

With the structure finished, I had to write some custom apex for the following two situations.
  1. When lots/products were being set up, the combined quantity of seed in the lots could not be greater than the total seed for the family.
  2. As product is added to opportunities or orders as Opportunity Product (line items) or Order Items, the quantity across all opportunities and orders for a single lot could not exceed the total seed in the lot.
With the Apex code, I throw errors back to the Salesforce/Trackland users when they try and add seed that compromises one of the two rules above.  The total configuration took me about 10 hours.   Pretty amazing to have a custom inventory management system in under 10 hours of configuration and development.  That is the beauty of Salesforce.  Add multiple price books in for custom pricing on a per group basis, and some pricing discounts for quantity breaks and you have a legit seed inventory management and sales system.