Using functions in Salesforce custom button or link URLs provides a way to dynamically determine behavior for Conga Composer parameters. This allows a Composer button or link to perform different functions based on certain criteria, including the values of fields in Salesforce. This logic can be applied using different Salesforce functions for various parameters or conditions within the Composer button URL. See Salesforce Help's Formula Operators and Functions Overview to familiarize yourself with the various functions available.

Using the methods described below, the functions are NOT selecting which Composer parameter to use but simply selecting the value to provide for a certain Composer parameter.

Example 1 - Simple IF Function

Let's say that you want to generate invoices from Opportunity records, but want to lock the file output format to PDF for all users with a profile other than System Administrator.

Logically, we want to set the value of the &FP0 parameter to either 0 or 1 depending on the profile of the current user.

  1. Create the parameter you'd like to provide a conditional value for, but leave its value blank.
  2. Insert the IF function (from the Salesforce drop-down).
  3. Define the logical test - The 'logical_test' clause will define the condition for what our parameter value will be set to. For this example, we'll insert the merge field for the User Profile ID, and specify that we want to define what value is provided when that equals "System Administrator."

    Within any Salesforce function, literal text is enclosed in either single (e.g. 'System Administrator') or double quotations (e.g. "System Administrator").
  4. Define the true and false values - The next step is to define what is displayed if the condition evaluates to "true." For our "true" value, if the user's profile is "System Administrator," we want to set FP0 equal to 0 so that the output file format is not locked. For our "false" value, the user's profile is not "System Administrator," we want to set FP0 equal to 1 so that the output file is locked.

  5. Test your solution to ensure your IF function is controlling the behavior as desired.

Example 2 - Evaluating Multiple Field Values - IF / OR / ISPICKVAL Function

The management team has dictated that an invoice can be generated with Conga Composer only if the Stage on the Opportunity record is one of three values: Proposal Made, Due Diligence, or Closed Won. We'll use the Composer DC parameter to specify this condition.

  1. Start with the DC parameter and the IF function:

    https://composer.congamerge.com
    ?sessionId={!API.Session_ID}
    &serverUrl={!API.Partner_Server_URL_290}
    &id={!Opportunity.Id}
    &DC={!IF
    (logical_test, value_if_true, value_if_false)}

  2. Next, because Opportunity Stage is a picklist field, which are only supported in certain functions, we must use the ISPICKVAL function to determine the value of the Stage field.

    https://composer.congamerge.com
    ?sessionId={!API.Session_ID}
    &serverUrl={!API.Partner_Server_URL_290}
    &id={!Opportunity.Id}
    &DC={!IF( ISPICKVAL(Opportunity.StageName, "Proposal Made"), value_if_true, value_if_false)}

  3. Replace value_if_true and value_if_false with the correct values for the DC parameter. In this example, the value_if_true is "0" because if the Stage is Proposal Made, we want DC=0, which allows Composer to run. The value_if_false is "1" because we want to disable Composer (DC=1) if the Stage is not Proposal Made.

    https://composer.congamerge.com
    ?sessionId={!API.Session_ID}
    &serverUrl={!API.Partner_Server_URL_290}
    &id={!Opportunity.Id}
    &DC={!IF( ISPICKVAL(Opportunity.StageName, "Proposal Made"), "0", "1")}

  4. Now we add the OR function because we have three approved values for Stage (if we only had one approved value, we could simply use the above IF / ISPICKVAL functions from step 3).

    https://composer.congamerge.com
    ?sessionId={!API.Session_ID}
    &serverUrl={!API.Partner_Server_URL_290}
    &id={!Opportunity.Id}
    &DC={!IF
    (OR ( ISPICKVAL(Opportunity.StageName, "Proposal Made"), logical2,...), "0", "1")}

  5. Replace logical2 and ... with the second and third Stage values, remembering to include the ISPICKVAL functions. Note the double closed parentheses )) after the "Closed Won" value to indicate the end of the OR function.

    https://composer.congamerge.com
    ?sessionId={!API.Session_ID}
    &serverUrl={!API.Partner_Server_URL_290}
    &id={!Opportunity.Id}
    &DC={!IF
    (OR ( ISPICKVAL(Opportunity.StageName, "Proposal Made"),ISPICKVAL(Opportunity.StageName, "Due Diligence"),ISPICKVAL(Opportunity.StageName, "Closed Won")),"0", "1")}

  6. Use the Check Syntax button at the bottom of the Salesforce button page to ensure you don't have any syntax errors. Now, go test your solution!

Example 3 - Evaluating Whether a Field Is Blank - IF / OR / ISNULL Function

If either the Case Principal, Case MRF, or Case Monthly Rate fields are blank (the ISNULL function evaluates whether a field is populated or not), we don't want Conga Composer to run (and would therefore want to enable the DC parameter to disable Conga Composer -- &DC=1). The following functions would accomplish this:

&DC={!IF( OR( ISNULL(Case.Principal__c), ISNULL(Case.MRF__c), ISNULL(Case.Monthly_Rate__c)), 1, 0)}