Salesforce - Custom Field Formula returning an ID code instead of the text name

146 Views Asked by At

In the Salesforce Case, I am trying to reference a Product Name from an Asset.

Currently in our Case layout you can do a lookup to find an asset connect with the case. I have a formula currently that will automatically fill out the serial number field on the Case page as well when the Asset gets linked.

I am trying to do a similar formula but want it to automatically fill out the Product Name that is associated with the Asset. However, the Product at the asset level is filled in by a lookup function to pull from our Product object.

When I do the formula in the custom field type I have it set to return as Text. I am using formula:

Asset.Product2Id

This give no syntax errors but is returning just a Product ID code instead of the name. I get syntax errors if I type the formula: Asset.Product2Id__r.Name

I am certain it is something simple that I am overlooking but I am struggling through figuring out what it needs to be.

I have tried:

Asset.Product2Id

Asset.Product2Id__r.Name

Asset.ProductDescription

Asset.Name (This one just pulls the name of the asset instead of the name of the product. Which makes sense)

Asset.StockKeepingUnit

1

There are 1 best solutions below

0
eyescream On

Asset.Product2.Name

Note how on Case itself AssetId is the real foreign key (lookup) field name but if you want to jump via dot - you use relationship name, minus the Id part. This is consistent for many SF standard objects.

For custom objects the raw field is Object__c and relation becomes Object__r.Name

You could read up a bit: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_query_using.htm

Or (if you don't have a better SOQL builder with some autocomplete) - the formula builder can help next time you need to go "up"? enter image description here