Questions tagged [formula]

A formula is an algorithm that derives its value from other fields, expressions, or values. Formulas can help you automatically calculate the value of a field based on other fields (from Salesforce doc). Formulas can be used in many areas of Salesforce other than just Formula Fields, such as Validation Rules and criteria for Workflow Rules and Approval Processes.

Filter by
Sorted by
Tagged with
54 votes
8 answers
75k views

How Can I Tell the Day of the Week of a Date?

I'd like to build in some logic based on the weekday (e.g. Monday, Tuesday, Wednesday) of a given date. How can I identify the date, using either formulas or Apex code?
Benj's user avatar
  • 11.2k
49 votes
3 answers
70k views

ISBLANK vs ISNULL

I am just wondering what could be differences between ISBLANK and ISNULL. I found following link http://shivasoft.in/blog/salesforce/salesforce-interview-questions-%E2%80%93-part-2/ But I think ...
doga's user avatar
  • 4,575
36 votes
1 answer
1k views

What are the compiled costs of each Formula function

Each formula function has a compiled cost that contributes towards the hard 5000 compiled character formula limit. What are the current compiled costs associated with each formula function?
Daniel Ballinger's user avatar
34 votes
5 answers
19k views

Refreshing Formula Fields Dynamically (without save)

I have an "invoice" custom object which has a couple of summarising formula fields in. I also have a complicated and dynamic visualforce page for building the invoice objects. As the user is ...
Simon Lawrence's user avatar
26 votes
3 answers
52k views

How do I get the base URL in the formula editor?

I'm building a custom button that when clicked creates a task. In the task comments, I'm building a URL to direct the assignee to the Account Team add page. I need to know the instance I'm on in order ...
Daniel Hoechst's user avatar
25 votes
6 answers
31k views

Is there a list of Salesforce images that can be used in custom pages and formula fields?

I have a Visualforce page that includes some Ajax functionality as follows: <apex:actionStatus id="searchtStatus" stopText=""> <apex:facet name="start"> Searching....<img ...
Peter Knolle's user avatar
  • 29.1k
20 votes
4 answers
9k views

Unexpected behavior with ISBLANK and CONTAINS functions in Visualforce Page

I've reduced my issue to the following example: <apex:page > <apex:variable var="blank" value="" /> <p> Contains(blank, 'foo'): <apex:outputText value="'TRUE'" rendered="{!...
Jason Clark's user avatar
  • 11.8k
16 votes
2 answers
11k views

CASESAFEID() apex equivalent

Is there any function in Apex which could emulate functionality of the CASESAFEID() formula function? I'm trying to get 18-char Id variant from the standard one.
dino ursic's user avatar
  • 2,323
15 votes
1 answer
29k views

How to display Picklist Label, instead of Picklist API in a Formula Field

I think the title says it all, we are using picklist values having different Label and API Name. How can I display the Picklist label instead of API in when using a formula field. I know I can use IF ...
jema's user avatar
  • 423
14 votes
5 answers
10k views

Refer to Record Type ID in Formula without Hard-coding

I'm building a Custom List Button in a Dev Environment, and I'd like it to work with no changes when deployed to Production even though all IDs will change. The list button (which will be displayed ...
Benj's user avatar
  • 11.2k
14 votes
3 answers
13k views

Find line break in formula field

I noticed that the Contact.MailingStreet field can be accessed line-by-line in reports with the Mailing Address Line 1, Mailing Address Line 2, and Mailing Address Line 3 fields. I want to create ...
Phil Rymek's user avatar
  • 6,159
14 votes
1 answer
770 views

Can someone confirm if I've identified a bug in Salesforce regarding formula fields?

I believe I've identified a bug in Salesforce related to formula fields. Can some of my fellow developers, and admins too, confirm if I am observing unexpected behavior? I do have a workaround. The ...
Coogle's user avatar
  • 445
13 votes
3 answers
3k views

Create a currency formula field with no decimal places for Standard Page Layout

We have the following challenge with currency fields: Scenario: On child record(s) (in a multi-currency org) we have pricing information which is stored as a currency value with 5 decimal numbers in ...
nisseknudsen's user avatar
11 votes
4 answers
1k views

Is There a Limit to Lightning Formula Parameters?

As I use the client side to enforce various pieces of business logic with aura:if statements, I'm finding that a given formula operator cannot handle more than two parameters. For example, this works:...
techbusinessman's user avatar
10 votes
2 answers
1k views

Field filter does not Work for Text Formula field used in SOQL

I have a simple SOQL query on Account which has a field Full_Address__c which is joint of Billing Street, City Zip. When I use this field as a filter it doesn't return the records: Example: String ...
Ashwani's user avatar
  • 22.6k
9 votes
1 answer
10k views

ISBLANK(Number Field) is not working

I am trying to create a formula field to count if there are any blank values on Number field. My formula is : if(ISBLANK(Number Field),1,0) However, it is always coming as '0' even if the number ...
Vimal Desai's user avatar
9 votes
2 answers
607 views

Formula field is not working as expected

I created a formula field to know the created task is for contact or opportunity or lead. So I tried to create a formula field Based on whatId & whoId. But it throws a syntax error. Can anyone ...
Pavan tej's user avatar
  • 1,450
9 votes
3 answers
3k views

Getting a birthday workflow to work

I am looking to run a workflow off a birthdate and notify my user that this birthday is coming up in 10 days. I am using this formula: (MONTH( Birthdate)) = MONTH(TODAY()) && (DAY( Birthdate))...
Bob Rickards's user avatar
9 votes
1 answer
8k views

How to reference Choice Value in formula instead of its label?

I have a Picklist screen component in a Flow which has many choices defined in the same flow: Now I need to make a formula that references the Choice Value of a given choice: If I use UPPER({!Plan} +...
ProgrammingLlama's user avatar
9 votes
1 answer
2k views

Roll up Count of booleans

Is it possible to use a roll up or formula field to count the number of "true" or "false" values on a boolean field of a detail record? Example: Account <-Master-----Detail-> My_Object__c ...
NSjonas's user avatar
  • 10.1k
9 votes
0 answers
864 views

Salesforce doesn't merge fields on email sent in platform event context

I have a process that runs every day in the morning. It is a scheduled class that publishes a platform event. When this event is run by the system, it collects some records and sends emails to some ...
Renato Oliveira's user avatar
8 votes
2 answers
13k views

decimal places and text() formula

When I use the text formula, salesforce doesn't respect my decimal place formatting. For example, Field A has 4 places to the right of the decimal. It shows up nicely on the page as 0.4000 If I'm ...
Shane McLaughlin's user avatar
8 votes
1 answer
5k views

Salesforce Long Text Area fields in formulas

Im using Professional Edition.Is there anyway to use long text area in formulas. Im searched most of the links but i didn't get any answer. Please tell me how to resolve the issues.
Udaya's user avatar
  • 1,014
8 votes
1 answer
4k views

Search formula fields using SOSL

Im trying to build a custom job board search on visualforce. I have a positions object which has a relationship has a master detail field to account. I'd like the search to return positions when you ...
Keith Mancuso's user avatar
8 votes
5 answers
14k views

Proper urlencoding of spaces in formulas syntax

1 week ago user has asked me to display a custom link on Account that would point to another system we use. Really straightforward stuff, idea being that user is already logged in to both SF and that ...
eyescream's user avatar
  • 24k
7 votes
2 answers
23k views

Remove whitespace before and after the string dynamically?

I am trying to remove whitespace (dynamically) from an input string: Input: ' inputString ' Output: 'inputString' Input: ' Ravi kumar ' Output: 'Ravi kumar' I want to remove the space before or ...
Ravindar Admin's user avatar
7 votes
2 answers
9k views

Number Field - Limit Four Characters - Validation Rules

I'm having trouble enforcing a minimum character requirement on a Salesforce number field (using Validation Rules). I can get the limitation to work on a text field using: AND( ISBLANK(...
Genko's user avatar
  • 636
7 votes
2 answers
2k views

Count Line Breaks?

I am trying to count the number of lines in the BillingAddress field. I am familiar with the following methodology to count the number of times a substring occurs via formula: LEN(TextField__c) - LEN(...
Adrian Larson's user avatar
  • 150k
7 votes
1 answer
6k views

Is there a Salesforce formula playground website / service / tool

I'm interested in using a Salesforce formula playground similar to: JS Bin - JavaScript Debugger JS Fiddle I've had a Google and cannot find anything. Does anyone know of a tool/website/service ...
Robs's user avatar
  • 9,330
6 votes
1 answer
16k views

How to query the data that has been modified in last 30 MINUTES

we have Order__c as custom object. we are trying to extract the past 30 minutes record. where LastModifiedDate=TODAY and HOUR_IN_DAY(LastModifiedDate) > 0.5 is not working We tried SOQL : ...
Sylphes's user avatar
  • 157
6 votes
1 answer
13k views

Process Builder - Add Minutes,Hours to Event End Date

I want to make the Event End Date as NOW()+60 Mins in process builder while creating a new Event record. But It is adding 60 DAYS even though Event End date is date/time field. How do I add minutes ...
sfdcFanBoy's user avatar
  • 4,055
6 votes
2 answers
4k views

Is is possible to have an automatic width or height on a photo in an image formula?

We have a photo image formula field thats showing student photos, using the technique found here: http://assets.salesforce.com/pdf/getting_started_with_images_v1.pdf (alternate link: http://www....
Keith Mancuso's user avatar
6 votes
2 answers
5k views

Can i create a formula field to calculate the time in business hours between Case created date to now/Closed date?

Can i create a formula field to calculate the time in business hours between Case created date to now/Closed date? I'm looking for a non code solution which is equivalent to finding the difference ...
Ganesh's user avatar
  • 799
6 votes
1 answer
592 views

How to differ between rollup-summary and formula fields using APEX Schema functions?

I'm using describe functions to retrieve a DescribeFieldResult. Now on an Object I have two fields: one is a formula and the other is a rollup-summary. How can I differentiate between these two "types"...
Uwe Heim's user avatar
  • 28.3k
6 votes
5 answers
13k views

Formula field for the Difference between 2 time values

I am trying to write a formula field that calculates the difference between 2 time values. The time inputs are picklist values that are in the format h:mm aa some valid values are 12:00 AM 9:30 AM 6:...
Daniel Blackhall's user avatar
6 votes
5 answers
5k views

How can I identify whether an Opportunity is a renewal?

My sales team would like a clear flag on Opportunity records indicating whether the Opp is a renewal or a new opportunity. The information should be displayed on the Opp record, and also available ...
Benj's user avatar
  • 11.2k
6 votes
1 answer
1k views

Check Parent Is Available before accessing in Process Builder Formula

Process builder bombs if you try and access a value on a parent relationship record on a record without a value for the parent relationship. For criteria this is easy to avoid by first checking that ...
Ralph Callaway's user avatar
6 votes
1 answer
93 views

More concise syntax

I'm trying to develop a scoring system for a survey and am having trouble making the syntax as parsimonious as possible in order to stay under the character limits when I start compiling formulas. I'...
Rich's user avatar
  • 61
6 votes
1 answer
10k views

Can YEAR() be used to with a DATETIME as it can with DATE [e.g. YEAR(Datetime__c)]

SFDC Documentations tells me YEAR "Returns the year component of a Datetime in the local time zone of the context user". http://www.salesforce.com/us/developer/docs/apexcode/Content/...
Justin J Carlson's user avatar
6 votes
1 answer
2k views

Validation Rule to count words

What I'm trying to do a validation rule to count number of words in a text field and return an error if field have more than 80 words. Validation Rule Condition Formula NOT(REGEX(TRIM( ...
Robertinho Sedinho's user avatar
6 votes
1 answer
1k views

Can existing formulas that reference encrypted fields be structured to work with or without Shield Platform Encryption?

We have a customer who wants to use Shield Platform Encryption but that has the constraint that you Can't reference encrypted fields in Formula Field Types with these alternatives suggested: Use WF ...
Keith C's user avatar
  • 136k
6 votes
3 answers
4k views

Formula for a workflow rule

I'd like to have a workflow rule fire when a record is owned by queue A and then changes owner. What I have so far is: AND( ISCHANGED(OwnerId), PRIORVALUE(OwnerId) = 'QueueId' ) I've tried both the ...
akarnid's user avatar
  • 1,984
6 votes
1 answer
2k views

Partner Account ID-Lead Object

There is Partner Account field on lead object. Salesforce help says, Description:ID of the partner account for the partner user that owns this lead. Available only if Partner Relationship Management ...
sfdc99999's user avatar
  • 3,585
6 votes
1 answer
357 views

Possible Bug in Spring '20 - Process builder formula doesn't save BR()

Since being upgraded to the Spring '20 release, a process that we have has stopped saving BR() in a formula to the Rich Text field it is populating. Formula in Process: "... next steps." + BR() + "&...
BrBarr's user avatar
  • 926
5 votes
2 answers
9k views

Formula field change doesn't cause trigger fire

Assume we have ObjectA__c with Field1__c and ObjectB__c with formula field Field2__c which is formula to ObjectA__r.Field1__c. I expected change of record field Field1__c of ObjectA__c would cause ...
Patlatus's user avatar
  • 16.4k
5 votes
7 answers
7k views

Differentiate Production/Sandbox Instance?

I know it is fairly straightforward in Apex to determine if the Salesforce instance is production org or a Sandbox org, but I wonder if the same is possible via formula? I have also read What are ...
Adrian Larson's user avatar
  • 150k
5 votes
4 answers
26k views

Unable to reference a formula field in roll up summary

I have a formula field Broker_value__c on opportunity product which is a currency field. I need a sum of this field for opportunities closed today in my opportunities. I also created a formula field ...
Prady's user avatar
  • 12.2k
5 votes
3 answers
18k views

Date Formula to Calculate date excluding weekends

I have a formula that is calculating the date from another date field + number of days and returning a date. test census dates field = Confirmed_Enrolled_Date__c + 16 I want to exclude weekends ...
syed88's user avatar
  • 93
5 votes
1 answer
3k views

Formula Specific to Running User?

I have a requirement where a certain field can be edited without the validations firing for a particular user. Now I tried to write rule like LastModifiedId != '005000000000000AAA' but the validation ...
User2529's user avatar
  • 703
5 votes
2 answers
2k views

Formula calculating calendar weeks (2015 vs 2016)

I've been using a formula to calculate the calendar weeks. Unfortunately it doesn't work for 2016, since 2015 had 53 calendar weeks. The results for 2016 are one higher than expected. Any ...
Atroxy's user avatar
  • 103

1
2 3 4 5
37