Archives

Apex Clear all fields for a SObject record

The clearOutRecords would iterate all the fields passed as the currentRecord, then: 1. Exclude the fields as part of the fieldsToExcludeForClearOut Set and relationship fields 2. Check if the field is not null and updateable 3. Special logic to set fields to predefined values 4. Set all other fields to null 5. Return the SObject […]

Rate this:

Read More

Salesforce Chatter Attaching Files to SObject

There are different ways you can use salesforce to attach a file to an SObject using Chatter. Apex Code Chatter REST Api Some limitations using this is using Blob for version.VersionData = attachment.Body; will run into Apex String length exceeds maximum: 6000000. Chatter Rest API POST https://cs43.salesforce.com/services/data/v35.0/connect/communities/0DB63000000003jGAA/chatter/feed-elements/batch HEADER Authorization         Bearer {sessionToken} Content-Type […]

Rate this:

Read More

Query SObject without burning SOQL queries

When you are writing Apex code you want to minimize the amount of SOQL queries in your code. One of the ways todo this is to create an SObject with some information of that object. Let us say you have the following SOQL query: Contact getAccountId = [Select AccountId from Contact limit 1]; Now you […]

Rate this:

Read More