Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 398

Questions relating to Apex, the native programming language for the Force.com platform. Use it for general questions on syntax, errors, constructs, and rules of use. Most questions should include a code *excerpt* to help answerers understand specifically what has gone wrong or why you need help.

75 votes
Accepted

What would be the best approach to get the recordtype id

.'); } } } return mapRecordTypes; } TO use this to accomplish your need within a Trigger or other Apex scenario, you can just do this: // Get all Active Account RecordTypes … Any hard-coded references to non-supported objects will cause your app to be disqualified from org editions which do not support such objects --- but use of Apex system classes and methods is fine no matter …
zachelrath's user avatar
  • 9,593
32 votes
Accepted

How can I determine how many future calls have been executed in 24 hours?

(1) To determine the number of Future calls run in the past 24 hours, you can use this utility method: public static Integer GetNumFutureCallsInLast24Hours() { return [select count() from AsyncAp …
zachelrath's user avatar
  • 9,593
18 votes
Accepted

How to get the attribute class list

; Decimal decimalValue = parser.getDecimalValue(); } else if (t == JSONToken.VALUE_STRING){ // Here, to determine advanced Apex object types, // you may have to apply some Regex or try/catch … stringValue = parser.getText(); if (stringValue.split('-').size()==3){ // We have a Salesforce Date value Date dateValue = parser.getDateValue(); } else { // and so on for other Apex
zachelrath's user avatar
  • 9,593
17 votes
Accepted

Where is the documentation for the CreatedBy object?

There is no CreatedBy object --- the CreatedById reference field, along with LastModifiedById and OwnerId, is (except in rare cases) a reference to the User object. Thus, querying for CreatedBy.UserNa …
zachelrath's user avatar
  • 9,593
16 votes

How can I make a PATCH HTTP Callout from Apex?

I had this same experience recently when trying to do a callout to the Google Calendar API, and apparently there's a common practice of servers listening for an X-HTTP-Method-Override header where you …
zachelrath's user avatar
  • 9,593
15 votes
Accepted

Managed Package Integration without Extensions or Dependencies

LEVERAGE NATIVE INTERFACES: You can also leverage built-in Apex interfaces such as Schedulable or Process.Plugin, which expose methods that all of your API classes can implement, providing a consistent … It's all based on storing your "API" within the constructors or properties of user-defined Apex classes. …
zachelrath's user avatar
  • 9,593
14 votes
3 answers
14k views

Execute an action / run a trigger every time a User logs in to Salesforce

Is there any way to consistently execute a piece of Apex code whenever a User logs in to Salesforce? …
zachelrath's user avatar
  • 9,593
14 votes
2 answers
6k views

How to access the Organization "Currency Locale" ISO Locale code (NOT Currency code) in Apex...

If anyone can find a way to retrieve this information from Apex / SOQL, I would be very thankful! … EDIT For confirmation that this info is not accessible from Apex/SOQL/Web-Services-API, I discovered that there is an Idea posted about this (with woefully few votes--- VOTE IT UP!) …
zachelrath's user avatar
  • 9,593
13 votes
Accepted

Is manual Database.setSavepoint() and rollback needed on Trigger exception?

The reason to use Savepoints and Database rollbacks is when you are doing multiple operations in a single transaction, and want to "roll-back" the entire sequence of operations if there was an excepti …
zachelrath's user avatar
  • 9,593
12 votes

Can I tell which fields are present in an sObject variable?

You can use JSON.deserializeUntyped() to convert any JSON-serialized SObject into a Map<String,Object> containing as its keys fields actually present on that SObject. Using your example with Account: …
zachelrath's user avatar
  • 9,593
10 votes
Accepted

How to get list of All Objects enabled with Activities?

The most accurate and quickest way is to loop over the list of valid target Objects of the WhatId field on the Task or Event object, as this list will change whenever you check/uncheck the "Allow Acti …
zachelrath's user avatar
  • 9,593
9 votes

50,000 query row governor limit

You don't need to do any sort of count query or roll-up summary at all --- a single Batch Apex class could iterate over millions of records if it needed to. … transaction -- but each time that the your Batch Apex class's execute() method is called constitutes a new transaction, so that Limit is reset every time that method is called. …
zachelrath's user avatar
  • 9,593
7 votes

Caching Expensive Results

Session/Local storage is definitely the way to go looking forward, as it's lightning fast, gives you plenty of storage space, and is all client-side, so after the first call there's no work at all done in Apex
zachelrath's user avatar
  • 9,593
7 votes
Accepted

A Chatter Feed related to a Record as well as a Chatter Group

Each Chatter FeedItem can only have one parent record - and if you'd like these FeedItems to show up in a record's chatter feed, e.g. using <chatter:feed entityId="{!recordId}"/>, then you'll have to …
zachelrath's user avatar
  • 9,593
6 votes
Accepted

Can I query the translated value and return the key in translation workbench?

There is currently no supported Custom Labels / Translations API from Apex, the Web Services API, or SOQL that you could use to achieve what you're after (the Map<String,List<String>> with the master language … BUT, if you don't, you can get these from the Web Services API or from within Apex through the DescribeFieldResult for this Picklist field, and then doing a getPicklistValues() call. …
zachelrath's user avatar
  • 9,593

15 30 50 per page