185

The Id Field Type is a base-62 encoded string. Each character can be one of 62 possible values: a lowercase letter (a-z) - 26 values an uppercase letter (A-Z) - 26 values a numeric digit (0-9) - 10 values As there is a combination of lower and upper case letters the casing of the 15 character Id has significance. E.g. 50130000000014c is a different ID ...


46

Queues are stored as a Group SObject, so select Id from Group where Name = 'My Group' and Type = 'Queue'


45

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_records.htm ROW_LOCK issue is very common if you have multiple users updating the record at the same time .Or say a batch job is running and is updating a record and same record another trigger or code snippet (usually a future method) is updating. Account [] ...


44

If it's not in Apex code you don't need the : and you need to add ( ) So your SOQL could be rewritten as: SELECT Id, Syndication_Documents__c FROM ContentVersion WHERE Syndication_Documents__c IN ('a4fa0000000KzbV','a4fa0000000KzbW') If you're doing it from Apex and have a Collection (Set, List, or Map) you can bind them to the query and avoid the ...


43

Explanation of the algorithm: This is based on the algorithm given here. The example below is using a made up salesforce 15 char Id 001A000010khO8J Separate the 15 char Id into 3 groups of 5 chars. You now have 3 strings (the triplet variable below): 001A0, 00010 and khO8J Reverse each string. The three strings are now 0A100, 01000 and J8Ohk In each string, ...


32

The first 3 digits are a prefix that specifies the type of sObject, a big list can be found here: http://www.fishofprey.com/2011/09/obscure-salesforce-object-key-prefixes.html I believe the rest of the Id is reference to the record itself. I should also add that the ID's are 15 digits long but can be 18 digits long with the last 3 digits for error ...


17

Despite what the docs would seem to indicate you are allowed to call getDescribe() on over 100 SObjectType objects in order to get their key prefix (the limits seem to apply to enumerating fields and global describes). I have an answer on a similar question with details on how to implement your idea, but there is a much cleaner way of doing this. To quote ...


16

I'm not sure that the case insensitive Ids work like that. With your all lowercase ID I'm guessing Salesforce is looking for an OpportunityShare (keyPrefix 00t) rather than a Task (00T). Odd that they aren't using the suffix information. The suffix is enough to make the ID appear to be insensitive in something like Excel, but it doesn't mean you can convert ...


16

Any valid 18-character Force.com record identifier. For example: ID id='00300000003T2PGAA0'; Note that if you set ID to a 15-character value, Apex automatically converts the value to its 18-character representation. All invalid ID values are rejected with a runtime exception. http://www.salesforce.com/us/developer/docs/apexcode/Content/...


15

//create an in-memory instance of code, with the external id set Code__c code = new Code__c(Code_Source__c = 'EXTERNAL_ID_HERE'); //create an instance of Opportunity, and point to the instance of code created above Opportunity op = new Opportunity(Name = 'Test Op', StageName = 'Open', ... , Oppoortunity_Code__r = code ); upsert op;


15

To convert it to 18 digits you can simply set it to an Id type variable: Id someId = '001J000001eun1Q'; Which will automatically convert it for you: system.debug(someId); // 001J000001eun1QIAQ Then you can simply call the getSObjectType() method on the Id variable which will return the object name: Schema.SObjectType objectType = someId.getSObjectType();...


15

As per Converting the Salesforce Pod Id to ServerUrl/Name, I started the mapping process from the source code of Workbench. That list however is largely out of date. As a community resource I've compiled the list from orgs I have access to. Please feel free to fill in gaps as you can. NA 30 NA1 (no longer exists) 40 NA2 50 NA3 60 NA4 70 NA5 80 NA6 A0 ...


14

While is is true that the last 3 character ads case insensitivity, I believe the algorithm used to generate them is the check digit. Check digits originated in legacy data transmission to alleviate the introduction if errors in the data. So a bit if both I reckon.


14

This is known as a "Unix Timestamp" (number of milliseconds since January 1st, 1970, 00:00:00 GMT). In Apex Code, you can use DateTime.newInstance(unixTimestamp) to return a DateTime that contains the formatted date/time value. In JavaScript, use new Date(unitTimestamp) to get the same result. To convert back, in Apex Code, use myDate.getTime(), and in ...


13

In my experience this usually means I've encountered an error and swallowed it. Do you have multiple required fields or validation rules that could error and stop the action method being invoked? The way I find out is to add an apex:pageMessages component to the page and rerender that as part of the actionfunction: <apex:actionFunction name="Update" ...


13

Should be able to add a target attribute:- <apex:commandLink value="{!LB}" action="{!totalbookedClick}" target="_blank"/>


13

SOQL always accepts 15- and 18-character Id values. You can test this in any program-- data loader, excel connector, Apex Code. The system does this for compatibility with older code that may only use 15-character Id values. Apex Code specifically tries to cast a string to an Id automatically when used as a value on a field that expects an Id. It also tries ...


13

(converted from comments) Thoughts on this strategy? You don't need to worry about such stuff Properly used queryMore() will take care of bringing you different records each time, keeping the "ORDER BY" you've selected. You issue one query (can be without "ORDER BY", depends what does your business logic demands) and keep calling the queryMore until the ...


13

Since you are just building a string, you need to wrap the Id in single quotes. SOQL = "select AuthorId,Name, Description,Type from Document where AuthorId='" + id + "'"; As was suggested in a comment, you should also escape any potentially harmful strings found in Id. I'm not familiar with the C# functions, but there should be some sort of URLEscape ...


13

I ported Daniel Ballinger's answer here to Apex: static String CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'; static List<Boolean> getBitPattern(String c) { Integer index = CHARS.indexOf(c.toUpperCase()); List<Boolean> result = new List<Boolean>(); for (Integer bitNumber = 0; bitNumber < 5; bitNumber++) result.add((...


13

Most of what you need to know is covered in What are Salesforce ID's composed of? In short, only the last 9 characters of the ID are incremented from record to record. E.g. 0010a0000000001 to 0010a0ZZZZZZZZZ. Giving you 629 possible identifiers for actual records on a pod for the same org. The three characters immediately after the keyprefix has other ...


11

This comparison actually uses the Id class. This means that it really isn't doing a String comparison, but rather a comparison of those two objects. The Id class will actually take into account the size of the Id (15 or 18) and ensure when it is compared with another Id that both are the same type. In short, it doesn't matter if you pass 15 or 18 length Ids....


11

Use DateTime's formatGMT to format the time according to your specs in GMT. String formatedDt = dt.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');


10

There are two methods to do this : 1)Use @Remote Action Call to call the method 2)Use ACtion Function and call on the event Here are the documentations for the same http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm Video of demo ...


10

You do not have any code in your example that will rerender anything. All you have is the rendered attribute which is only determined when the page is originally loaded. You should try using the apex:actionSupport Visualforce functionality. Your page would look something like: <apex:page standardController="Event" extensions="CVFC_EventPage_ctrl_Dev" >...


10

Use Following method to get the SObjectType Id someId = '00590000000eF8z'; System.debug(someId.getSObjectType()); Output : User


10

No, there's no way to tell if a key exists or not. We don't have access to "containsKey", and any attempt to reference a key that doesn't exist will cause your code to crash and burn catastrophically. Visualforce Error Help for this Page Map key 'value' not found in map Error is in expression '{!not(isnull(keys[key]))}' in component <something> in ...


10

You can clone the entire attachment and then delete the old one. this code works for me : List<Attachment> attachmentsToInsert = new List<Attachment>(); List<Attachment> attachmentsToDelete = new List<Attachment>(); Attachment tempAtt; for(Attachment attachment: [ SELECT SystemModstamp, ParentId, OwnerId, Name, ...


10

Parallel to Adrian's response I also cooked up my own version for reference; public static Id correctCapitalizedId(String input) { String keyString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345', result = ''; Integer i = 0, s = 15; if (input.length() != 18) { return null; } for (String seq : input.split('(?<=\\G.{5})')) { ...


10

No. IDs are not always sequential, you don't know the volume of records created by other tenants, IDs are globally unique, and records are deleted all the time. Having worked at Salesforce, I got this question a lot, and the answer is that you shouldn't read anything into the record IDs. Plus, with prefixes set for custom objects, you have no idea how many ...


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