You are here:
single
Returns the first and only record of a list in Salesforce Spiff. This function validates that only one record is returned and converts the list of records into an individual record.
Required Editions
| Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience |
| Available in: Enterprise, Unlimited, and Developer Editions |
| Available for an additional cost in: Professional Edition with Web Services API Enabled |
Syntax
single(list, string)Arguments
| Argument | Required? | Description |
|---|---|---|
| list | Required | The list that contains only one record. |
| string | Optional | An error message that tells admins that the list includes more than record and explains how to remove extra records. |
Example
An opportunity can have multiple line items, but maybe you want to verify that an opportunity includes only one line item of a specific type.
First, use the filter() function with the Opportunities and Opportunity Splits relationship to return a rep's deals that have "ARR Amount" in the description.
=filter(OppToOppSplits, OppSplitToSplitType.Description == "ARR Amount" AND SplitOwnerId = rep.Id)Next, use the transform_list() function to turn the filtered list of deals into a list of records that have "ARR Amount" in the description.
=transform_list(filter(OppToOppSplits, OppSplitToSplitType.Description == "ARR Amount" AND SplitOwnerId = rep.Id), OppSplitToSplitType.Description == "ARR Amount")If you expect to have only one record with this description, use the single() function to verify that the list includes only one record. If there's more than one record, return an error message to help the admin troubleshoot.
=single(transform_list(filter(OppToOppSplits, OppSplitToSplitType.Description == "ARR Amount" AND SplitOwnerId = rep.Id), OppSplitToSplitType.Description == "ARR Amount"), "We found multiple split records with ARR Amount in the description.")
