Saturday, November 30, 2019

How to remove ‘noreply@salesforce.com on behalf of’ on email sent from salesforce

Salesforce automatically adds the "no-reply@Salesforce.com on behalf of" to the sender field on emails sent from Salesforce.
To remove the "no-reply@Salesforce.com on behalf of" we have to deselect the "Enable Sender ID compliance" permission in email delivery setting.

Path:
From Setup, enter Email Administration(Classic) || Email(Lightning Experience) in the Quick Find box, and then Deliverability
Under the Email Security Compliance section, Deselect the Enable Sender ID compliance box and then click Save.


Monday, November 25, 2019

Undelete trigger event in apex trigger in Salesforce


Before Undelete

The record is available, but the field isDeleted set to True. the before undelete trigger wouldn’t be able to see the records(values) that it needs. due to this reason, there is no before undeleting operation available.

After undelete

The after undelete trigger event only works with recovered records—that is, records that were deleted and then recovered from the Recycle Bin through the undelete DML statement. These are also called undeleted records.

Ex:
If you delete an Account, an Opportunity may also be deleted. When you recover the Account from the Recycle Bin, the Opportunity is also recovered.
If there is an after undelete trigger event associated with both the Account and the Opportunity, only the Account after undelete trigger event executes.

The after undelete trigger event only fires for the following objects:

  • Account
  • Asset
  • Campaign
  • Case
  • Contact
  • ContentDocument
  • Contract
  • Custom objects
  • Event
  • Lead
  • Opportunity
  • Product
  • Solution
  • Task

Tuesday, November 19, 2019

How to get recently viewed information of user in org using SOQL

Salesforce stores the recently viewed information in RecentlyViewed object
RecentlyViewed represents records that the current user has recently viewed or referenced (by viewing a related record).

If you want to query the multiple sObject records recently viewed information.
Ex: I want to see the recently viewed account and contact records in org.
Select Id, Name, Type, LastViewedDate, Profile.Name FROM RecentlyViewed WHERE Type IN ('Account', 'Contact') ORDER BY LastViewedDate DESC



You can also use the LastViewdDate field on the sObject. 
Ex: I want to see only recently viewed Account records.
SELECT Id, Name, LastViewedDate FROM Account WHERE LastViewedDate != NULL ORDER BY LastViewedDate DESC limit 5


Resource
RecentlyViewed Object