Tuesday, April 23, 2019

Cross-Object Formula Field Not Visible as a Filter for My Roll-Up Summary Field

I ran into some issues this week, trying to add a Roll-Up Summary Field on the Order Object. Specifically, I had recently added a cross-object formula field to the Order Products object, and I was trying to determine how many Order Products of a specific type (Hardware) were associated wiht the order. Here are the details and the work around I learned (with a little help from my friends):

OBJECTIVE: Track the number of hardware products that had been added to an order.

BACKGROUND: I'm adding the ability to track customer orders through the order fulfillment process for one of our Salesforce teams.  We're using the standard Order object, and associating Order Product records to that order.

Setting up a field to track the total quantity of products (Total_Product_Qty__c) that were on the order was straight forward: a simple roll-up summary field on the child OrderProduct.Quantity field did the trick.



In the Product2 object, we use the Family field to distinguish what type of product that item is (Hardware, Subscription, Service, etc.).


I thought the process for setting up a roll-up summary field on the Order object, getting a count of all Order Objects that were of type Hardware would be straight forward: I set up a cross-object text formula on the Order Product (OrderItem) object to pull in the Family field from the Product2 object (i.e., the OrderItem's related PricebookEntry.Product2.Family).

I created the cross-object formula field on the Order Product object with no issue, but when I tried to add a roll-up summary field on the parent Order object, using that new cross-object formula field as a filter, the cross-object formula field wasn't visible as a selectable filter.

Admin Secret: 90% of being a Salesforce Admin is having strong skills in Google Fu, the art of finding information you need from somewhere else out there on the web.

I googled "can't do a roll-up summary of custom fields on order product object" and found this article by Ariel Ward, with solutions by Steve Molis and Narender Singh. The gist of it boiled down to the fact that you can't use cross-object formulas in a roll-up summary field.

THE SOLUTION: I kept the formula field on the Order Product object, but added a custom checkbox field (HW) to the object, as well. I used a Process Builder flow to set the checkbox to True if the cross-object formula field had a value of "Hardware".

This checkbox field was selectable as a filter on the parent Order's roll-up summary field, so I was able to add a "Total_HW_Product__c" as a roll-up-summary field on Order Product > Quantity, with a filter of HW == TRUE.



Saturday, April 20, 2019

How to Pass a Record ID to a Flow Evoked by an Action Button

I wanted to add a button on a Lightning Record Page, and pass the record ID to that flow so I could perform various conditional actions within the Flow, based on field values on the record.
The solution is straight forward, but finding out exactly how to do it took longer than I expected it to. The process is documented in Salesforce help docs (kinda), but when I tried to find specific examples with my Google Fu, I found a ton of misinformation out there. Well, not so much misinformation as it was “stale” information. It wasn’t always possible to pass a record ID to a flow from an Action Button in Lightning, so clever Salesforce Admins and Developers found hacks, like embedding the flow in a Visualforce Page, and calling the VisualForce page from an Action Button. Now that Flows can be implemented directly on from an Action Button in Salesforce, the process for passing the record ID is straight forward: create a variable (data type: text) in your flow named “recordId”. If the Flow is being evoked from a Record Page, Salesforce will give the flow context by automatically passing the ID value of the current record to the flow. Here’s a step-by-step walkthrough. We’re going to make a very simply Flow, which simply displays the current record ID in a pop-up window.
  1. Navigate to Setup > Flows. Click the “New Flow” button.
  2. In the left pane Toolbox, click “Manager” and then the “New Resource” button. Salesforce will prompt you to enter the Resource Type. Select “Variable” from the drop down menu.
  3. In the New Resource variables declaration box, enter the following values:
    1. API Name: recordId
    2. Data Type: Text
    3. Select “Available for input”
    4. Click “Done”
  4. In the Toolbox Elements Tab, click “Screen” and drag it onto your canvas.
    1. In the Screen Properties section (right pane), give the flow component a Label and API Name (in my example, I use “Show Record ID”).
    2. In the Screen Components section (left pane), drag the “Display Text” component into the Screen element. Give it an API name. In the text block section, type: “The record ID is: {!recordId}”. Here, {!recordId} references the variable that was passed in at 3.1 above.
    3. Click Done
  5. Connect the Start element to the Screen element. Click Save. Salesforce will prompt you to enter:
    1. Flow Label: type “testShowRecordId”. Salesforce auto-populates the API Name with the same value.
    2. Type: Screen Flow
    3. The Flow is created in a deactivated state. To Activate it, from Setup > Flows screen, click the “testShowRecordId” label, then click “Activate”.
  6. We’ve got our flow! Now we need to add it as an Action Button on an object. You can do this for any object, but in this example, I’ll use the Opportunity record:
    1. Click Setup > Object Manager.
    2. Do a Quick Find on “oppo” and select “Opportunity”
    3. Select “Buttons, Links and Actions”, and then click the “New Action” button
    4. On the New Action screen, enter the following, and then click save

  7. Almost done! Now that we have an Action Button created, let’s add it to a page layout. Click “Page Layouts”, select “Opportunity Layout”.
    1. Select “Mobile & Lightning Actions” from the top banner. The “Show ID” button we just created should be visible.
    2. Drag “Show ID” down into the “Salesforce Mobile and Lightning Experience Actions” section of the page.
    3. Save the page layout, and then open an existing Opportunity
  8. You now have a Show ID button visible. Once you click it, it shows the ID of the record
From here, you can start adding more to your Flow, like the “Get Records” element to pull in additional details of the contextual “recordId” that we passed in. With that, you can set up conditional logic based on the field values of the record. Hope you found this helpful, and that it saves you more time than it took for me to figure out how to give the action-button triggered Flow context about what record it was evoked from.

Tuesday, April 16, 2019

College Not Requried


This blog inspired by a recent article I read on LinkedIn: https://www.linkedin.com/feed/news/no-need-for-a-degree-to-succeed-4392019/ It's becoming increasingly common -- even among large tech companies -- that a 4-year degree is no longer required. This mostly stems from a deficit in candidates applying for jobs at companies that really need skilled talent to work for them. This will become an even bigger problem as "baby boomers" start to age out of the workforce. As a hiring manager, a 4-year degree largely meant: (1) your younger self was committed to learning new things. I expect that you are going to still be interested in doing that once you join my team. I need "constant learners" because the world is constantly changing. New tools, new methods, new approaches to getting work done. Be willing and eager to learn, always. (2) your younger self was flexible, and had the patience to put up with a lot of bullshit that the college programs threw at you: juggling heavy course loads, the craziness and stress of both midterms and finals, dealing with crazy / oddball peers, TAs and professors. You put up with a lot. I hope you'll find it easier, by comparison, here at the office, but I expect your habits of flexibility and patience will continue -- you'll need them here! (3) you have a portfolio of accomplishments: hopefully, if you haven't kept them in an actual portfolio, you're able to articulate them to me in an interview. If I hear about the great things you've accomplished, I can relate them to the projects I know you're going to encounter here in the business world. And here's the secret: you DON'T need a college degree for any of those. I love hiring veterans, because their four (or more!) years gave them all of these experiences and more. You know who else impresses the hell out of me? Stay-At-Home-Moms (or Dads!) returning to the work force. Talk about people having their shit together, adept at learning new things, practicing extreme patience -- and willing / able to sacrifice their careers just to nurture and develop their young child! Have neither a college degree, military service, SAHM/D status to fall back on? That's ok -- but be ready to show me how you spent your recent years: (a) learning new things, (b) being flexible and patient, (c) and most importantly, show me a portfolio of your accomplishments. What personal projects have you been working on in your basement, garage, backyard or down at the local makerspace? What free, online learning programs have you completed? How have you been working to make the world a better place through your volunteer efforts? What small business did you try to jumpstart as an entrepreneur? Tell me about the obstacles you have overcome. The bottom line is you still have to put in the effort, even if it's not a college degree, military discharge and service records, a healthy, well-adjusted kid, or small-business that you're showing off at the end. You don't need work experience, but you need EXPERIENCE. Here's what won't cut it: staying in your "comfort zone". Working 30-40 hours a week at that same front-end job you got right out of high school, all while living in your parents basement and spending the bulk of your free time playing video games. If you're in that rut right now, find a way to break free. Start working on an ambitious project, volunteer at a local non-profit, set goals and work toward them, find a mentor, keep a journal and build your portfolio. Demonstrate you are trainable and worth investing in. That's the right stuff and I'd hire you.