Skip to main content
11 votes
Accepted

Apex differentiate between RichTextArea, LongTextArea and TextArea

Looks like theres 3 methods you can use to check the definition of a textarea: field.getType() == Schema.DisplayType.TEXTAREA field.isHtmlFormatted() field.getLength() Here's a snippet of these ...
battery.cord's user avatar
  • 8,845
10 votes
Accepted

How to check if SObject has certain field?

All the keys in the map are in lower case for some reason. I get a positive result for ownerid but not for OwnerId. I checked for our account object and all the keys in the map are lowercase. This i ...
Kasper's user avatar
  • 2,907
10 votes
Accepted

Apex differentiate between Lookup field to master detail field

You want to call getRelationshipOrder() from your describe. It will be null for a lookup, 0 or 1 for a Master-Detail relationship.
Adrian Larson's user avatar
  • 151k
9 votes

What is the best workaround for the 20 field history tracking cap?

@sfdc's method will consume a lot of Data Storage -- and that's expensive! Do what @sfdc said but store the data in JSON in a Long Text Area Field on the record. Then build a Visualforce Page that ...
Scott Pelak's user avatar
  • 7,564
9 votes
Accepted

Is it possible to copy fields from Sandbox to Production?

Yes, you can use a change set to deploy fields from a sandbox to production. First, in your Production org, go to "Deployment Settings" and edit your sandbox's deployment settings to allow inbound ...
IllusiveBrian's user avatar
8 votes
Accepted

Is there a way to see all recent changes in an org

Monitor Setup Changes Setup Audit Trail tracks the recent setup changes that you and other admins have made to your org. Audit history is especially useful in orgs with multiple admins. To view the ...
Adrian Larson's user avatar
  • 151k
8 votes
Accepted

How can one validate 'recordEditForm' fields before submitting them to the platform?

Here's a way that you can achieve this. Let's say I have the component as below. There's a field for Title, which is hidden when the component is rendered (and your use case is to enable that). This ...
Jayant Das's user avatar
  • 30.6k
8 votes
Accepted

The length of the first and last names

A quicker way to do that is to use describe call in Apex. System.debug(Contact.FirstName.getDescribe().length); //Prints 40 System.debug(Contact.LastName.getDescribe().length); //Prints 80 It also ...
Pranay Jaiswal's user avatar
8 votes
Accepted

How to iterate over all the queried out fields of a single record

You just need sObject.getPopulatedFieldsAsMap(): for(Object value: record.getPopulatedFieldsAsMap().values()) { if(value == true) { // We found a match } } If you need to know which field: ...
sfdcfox's user avatar
  • 497k
6 votes

Text Formula String Concatenation - Omit Trailing Comma

@AdrianLarson I used your suggestion for a similar solution and it worked for a year or so, until I was asked to include more Checkboxes (12 in all) in the formula, then I got: Error: Compiled ...
JLanders's user avatar
6 votes
Accepted

How to check that SObject field is present in SOQL query

There is a new method on sObject(as of Summer 16) for this: getPopulatedFieldsAsMap() https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#...
Aidan's user avatar
  • 13.8k
6 votes
Accepted

How to edit the "created by" field for case attachments?

Take a look at this help article: Considerations before having Create Audit Fields enabled: Salesforce has the ability to set system fields through the API. When you are migrating data from an ...
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Maximum Number of Fields in Data Extension

From inspecting the wsdl (the API schema), the maxOccurs for Data Extension fields is unbounded which implies that there is no limitation.
Eliot Harper's user avatar
  • 16.6k
6 votes
Accepted

List of all objects with the current number of used custom fields

I'll convert this comment into an answer. You can obtain this data rather clumsily with the Tooling API in the Developer Console. Enter the following in the Query Editor, and check the "Use Tooling ...
David Reed's user avatar
  • 93.2k
6 votes
Accepted

Accommodate the length of a string value to prevent the STRING_TOO_LONG issue

You can use the allowFieldTruncation header in the DMLOptions Class. Order record = new Order(...); Database.DMLOptions opt = new Database.DMLOptions(); opt.allowFieldTruncation = true; Database....
sfdcfox's user avatar
  • 497k
6 votes

The length of the first and last names

you can check details about fields on Contact SOAP API guide FirstName - The contact’s first name up to 40 characters. LastName - Required. Last name of the contact up to 80 characters.
Oleksandr Berehovskyi's user avatar
5 votes
Accepted

No such column 'Type' on entity 'LookedUpFromActivity'

If you look at LookedUpFromActivity object. There is no Type field, instead you can use ActivityType or ActivitySubtype field
Raul's user avatar
  • 18.8k
5 votes
Accepted

Only allow whole number in field

You could write a validation rule: FLOOR(Field__c) <> Field Keep in mind that normally, the system stores exactly what the user entered, despite not showing it on the screen. So, for example, ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

What is the best way to mass update the field labels of a custom object in Salesforce?

An IDE is arguably the easiest way to edit fields. Simply pull down the object, edit all the labels, then save the changes. You can do this in MavensMate, Force.com IDE, and others that support the ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Automate the process of picklist values retrieval from the backend

I've already written an answer about this, but the question doesn't make sense to call it a duplicate, so I'll repost that code here. // Wrapper class to provide label/value. public class ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

How to access fields returned by Polymorphic query in apex/soql?

Here is an example of how to retrieve field values returned from Polymorphic query. list<Event> newlist=[SELECT TYPEOF WHAT WHEN OPPORTUNITY THEN StageName ...
Santanu Boral's user avatar
5 votes
Accepted

SOQL SORTING WITH 2 FIELDS

Generally speaking, when I have a question, the first place I look is at the documentation. Ordering by multiple columns is listed in ORDER BY in the SOQL & SOSL documentation (emphasis mine) ...
Derek F's user avatar
  • 62.8k
5 votes
Accepted

Send only udpated fields instead of all the field information

You can use the CDC (Change Data Capture) to get updates only on updated fields. You could also write manual code (Apex) to create a change delta, although this might require a lot of CPU time ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

View object fields and data

If you are talking about a quick select rather than typing all the fields, Workbench is the best tool for me. You can navigate into query > soql query and from below view you can select all the fields ...
highfive's user avatar
  • 6,241
4 votes
Accepted

Text Formula String Concatenation - Omit Trailing Comma

I think this is how far you have to go to implement formula here. I'm doubtful its compile size will be under the limit, but I haven't checked. IF(Sunday__c, 'Sunday' & IF( OR(Monday__c, ...
Adrian Larson's user avatar
  • 151k
4 votes

Check if field is available on page layout

Vote for this idea if you feel the requirement is necessary for you: Make Page Layout data available to apex via SOQL or Schema class Page layout data should be available via the Schema apex class ...
sidasu92's user avatar
4 votes

Formula based field in account instead of Roll-Up Summary

Using a formula field to count related records is not possible. You have a few options: Trigger to roll up in real time Batch job to perform rollup DLRS Package (Declarative Lookup Roll Up Summary) ...
Eric's user avatar
  • 54.2k
4 votes
Accepted

How can I distinguish the different Textarea fields in apex?

This seems to work for short vs long: http://www.fishofprey.com/2011/03/find-length-of-salesforce-field-in-apex.html When I test the following in my org: System.debug( Schema.SObjectType.Contact....
Charles T's user avatar
  • 11k
4 votes
Accepted

How to query more than 800 fields in query using Bulk load query

See the SOQL Limits Guide. There's a number of limitations that will prevent you from exporting objects of this size in one go, including total character limit, number of large text area fields, total ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

No such column 'QuantityUnitOfMeasure' on entity 'Product2'

As far as I can tell, you need to be using API v.39 or higher to access this field. This seems to be part of a new feature, as it doesn't appear in most of the documentation yet. It is mentioned here, ...
Sequoyah's user avatar
  • 760

Only top scored, non community-wiki answers of a minimum length are eligible