function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mr.sollismr.sollis 

two fold question

thanks for your time in advance, I have two seemingly easy questions that have me stumped.

 

1) When are Formula fields (specifically with a lookup field to another object) updated?  instantly? when they are viewed in the UI?

  • I ask because I have a custom field on the contact, a formula field, that simple brings down the textual information from the user object, connected to the account.  So it looks like this: Contact -> Account (custom related list field) -> User -> Name
  • I am finding (I think) that the forumula field on the contact does not always match the user on the account it is pulling from


2)To validate this concern directly from the API I am trying to run this query:

 

  • select
        account.account_adm_owner__r.name,
        adm_owner_from_account__c
    from
        contact
    WHERE
        account.account_adm_owner__r.name!=adm_owner_from_account__c
  • I get an "invalid token" error on "!=adm_owner_from_account__c"
 
Thank you again for any guidance you can provide.
Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

1) formulas are evaluated upon data read (UI page view, or api query).

 

2) where clause comparisions in SOQL need to be against literal values, not other fields. 

All Answers

SuperfellSuperfell

1) formulas are evaluated upon data read (UI page view, or api query).

 

2) where clause comparisions in SOQL need to be against literal values, not other fields. 

This was selected as the best answer
mr.sollismr.sollis

Excellent.  Thank you.  That is as I expected.

 

We are using DBamp, which uses the api, to bring data down to SQL server as backup and for adhoc querying, the values do not match on our backup (which was derived from the api)

 

is there any chance something with the sync, or the API read (perhaps a header value in the soap call or something) that I could force the update of the formula fields?

 

thank you again, this is very helpful.

werewolfwerewolf
What do you mean, force the update of formula fields?  As Simon said, they are calculated when the data is read -- so whenever you look at a formula field, wherever you look at it, it is freshly calculated.
mr.sollismr.sollis

Sorry, re-reading I realize that was confusing. My bad.

 

I think I know what the problem may be.  We are doing "incremental" updates based on lastmodifieddate.  I do not believe when a forumula field updates, that it changes that particular date, which would [over time] create the disrepency in our backup between the contact lookup field and the original account field.

 

Do you know if using the system mod date would solve that problem?   

 

Many thanks.