anusha(salesforce developer)

Wednesday, 27 July 2016

Cross-Object Formula in Salesforce

Create a cross-object formula on a detail or child object to reference or display data from the parent object, or its own parent objects.

You can reference data from objects up to 10 relationships away.


Using the Owner Field

Some objects support different object types for the Owner field, such as a User, Queue, or Calendar. On objects that support this behavior, when creating a cross-object formula using Owner, you must be explicit about the owner type you’re referencing.
For example, if you need owner email and you don’t use queues, your formula would be Owner:User.Email. If you do use queues, your formula could be
IF( ISBLANK( Owner:User.Id ), Owner:Queue.QueueEmail, Owner:User.Email )
Here’s how you would select Owner object fields on a Lead in the Advanced formula tab:Formula Span to Owner
Note
  • Owner references aren’t supported in Visualforce pages. For example, on a page with Case as a controller, you can’t include {!Case.Owner:User.FirstName}. However, you can include an existing spanning formula on a Visualforce page. For example, if you have a custom text formula MyFormula__c on a Case with valueOwner:User.FirstName, you can include {!Case.MyFormula__c} on your Visualforce page.
  • Owner references aren’t supported on the Queue object. For example, you can't referenceOwner:Queue.Owner.Email.
  • If your formula has Owner:User.fieldname and Owner:Queue.fieldname, both of these count against the limit of 10 unique relationships per object in cross-object formulas.
  • On objects that don’t support Queues, User is implicit when referencing Owner. Your formula should beOwner.fieldname, not Owner:User.fieldname.

Using Profile.Name

The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected; however, in list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure the formula always returns the intended result. For example:
IF
     (OR
          (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), 
     "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable

No comments:

Post a Comment