Quantcast
Channel: Conga » Blog
Viewing all articles
Browse latest Browse all 95

How to Convert a Salesforce Custom Button to a Formula

$
0
0
Happy Friday, everyone!  Before we crack into today’s edition of Tips & Tricks, I want to extend a big thank you to everyone who made it to the Denver Salesforce User Group meeting last week hosted here at the Conga Ranch.  We had an amazing turnout and it’s always great to see such a vibrant Salesforce community here in Colorado.  We live blogged it if you’d like a recap, and @CongaPete and @BrentDowney were heroic as usual:
 
 
But all superheroism aside, let’s get down to business.  Have you ever wanted to create hundreds of documents at once?  How about sending batches of complex emails on a schedule?  What about creating and delivering a file in response to a Salesforce workflow rule?  If so, then Conga Conductor or Workflow are the answer to your batched, scheduled or event-driven needs.
 
Oh &*%$, a Sales Pitch?
 
Definitely not!  Conga Conductor (for batching and scheduling) and Workflow (for event-driven solutions) are paid add-on products to Composer, but I’m not here to sell you on them.  Instead, I want to guide you through arguably the trickiest part of setting up a Conga Conductor or Workflow solution so that if you decide to check out either product, you’ll be able to hit the ground running and turn your requirements into a working solution as quickly as possible.
 
How to Convert a Salesforce Custom Button to a Formula
 
Converting a Composer button URL into a Salesforce formula is one of the key steps to setting up either Conductor or Workflow, so let’s go through a step-by-step example of how to make that happen.
 
Step 1: Create a Working Conga Composer Solution
 
Best practice will be to first create a Composer solution that works exactly as intended when run from a custom button on a single Salesforce record.  This takes away a lot of the guesswork and gives you a great starting point for converting your Composer button URL to a text formula.  I’ve got a Composer solution that creates and emails receipts from the Opportunity object, so we’ll be converting that to a text formula.
 
Step 2: Copy Your Composer Button URL
 
For this example, we’ll start by copying the following Composer button URL:
 
 
Step 3: Create Your New Formula
 
The next step will be to create a formula field on your master object (the object where your original Composer button is located).  In my case, it’s the Opportunity, so I’d navigate to:
 
Setup->Customize->Opportunities->Fields->New Field
 
I recommend naming your new formula field something very similar to your button, but adding “URL” at the end of the name.  My original Composer button was called ‘Email Receipt’, so I’ll name this new formula ‘Email Receipt URL’.
 
 
Then, select the return type of ‘text’.  The little description next to the text formula option explains exactly what we’re about to do here: “Create a text string, for example, by concatenating other text fields.”
 
 
Step 4: Concatenate Your Formula
 
Excel gurus are likely familiar with the concept of concatenation, but for the rest of us mere mortals, concatenation is the process of joining of separate text strings together to create one continuous string.  For example, the concatenation of “snow” and “ball” is “snowball”.  We’re going to do exactly this with the lines of text from our original Composer button URL.
 
We’ll first paste our entire URL into the formula window:
 
 
To successfully concatenate this formula, we’ll be following a few general rules:
 
1) The first 3 lines of our formula will be deleted (the Composer web address, the SessionID and the ServerURL).
 
2) Literal text will be surrounded by double quotations (“ ”).
 
3) Merge fields from the button must be replaced with the corresponding field available in the formula, and will be referenced OUTSIDE of double quotations.  Because fields will return their correspondent field value, they aren’t literal text, so we position them outside the quotes.
TIP: Any field surrounded by curly brackets (a merge field) will need to be replaced.
 
4) Each line of the formula will be concatenated with the next line by using ‘+’ signs.  You can also use the ‘&’ symbol, but because that’s used with each Composer parameter, I highly recommend using the ‘+’ sign for clarity.
 
5) Spaces are permitted in a formula if they’re part of literal text (i.e. surrounded by double quotes).
 
6) You’ll also need a &QMode parameter for Conductor or Workflow.  The &QMode parameter controls the behavior of Conductor or Workflow, like whether a solution should email a file or attach it to a record in Salesforce.
 
Let’s break down how I applied those rules to successfully convert my button URL into a text formula:
 
 
1) These first 3 lines of the original button URL have been deleted.
 
2) Here, we see an example of how literal text (&Id=) should be surrounded by double quotations.  We also see how a merge field (the master object ID) from our original button URL has been converted to its corresponding field available in the formula.  You can do this by clicking the ‘Insert Field’ button when editing your formula.
 
3) For my &OFN parameter, we see how spaces can be enclosed within literal text.  If I kept the + signs intact, they’d actually show up in my output file name.  This is also another good example of how a merge field (Opportunity Name) is converted to a field reference in our formula.
 
4) PROTIP: The {!Contact.Id} merge field in my Opportunity button URL was retrieving the Contact ID of my Primary Contact Role.  The converted ‘ContactId’ field isn’t actually available from the ‘Insert Field’ menu, but you can still use it in your formula to retrieve the same value.  Formula hacks!
 
5) Finally, we see that I’ve added my &QMode parameter and assigned it a value of ‘3’.  This will set up my solution, whether for Conga Conductor or Conga Workflow, to email my receipt.
 
Step 5: Put It in Context
 
Now that we’ve successfully converted our Conga Composer button URL to a text formula, we have some choices about what to actually do with it.  If we’re looking to create a batched or scheduled solution with Conga Conductor, we’d then choose how we’d like to launch that process in Salesforce.  If we’re looking to create and distribute a file in response to a Salesforce workflow rule with Conga Workflow, we’d then choose what kind of workflow rule we want to trigger our solution.
 
A quick word of caution: Conga Conductor and Conga Workflow solutions vary tremendously depending on the use case.  In that sense, it’s safe to say that every Conductor or Workflow solution is unique.  This post is geared to help you through one part of the setup process for either type of solution to get you up and running as quickly as possible.  If this post got you thinking about batched, scheduled or event-driven solutions but left you with questions about the whole process, I’d encourage you to get in touch with us.  Support is kind of our thing around here.
 
Have an awesome weekend, and don’t forget to subscribe so you never miss a post!

Viewing all articles
Browse latest Browse all 95

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>