50

Salesforce platform has a feature ROW LEVEL Security. This feature ensures that sharing and visibility set by salesforce administrators for the records have to be maintained. As a part of this feature, there are sharing calculations that the platform has to perform when the record ownership is changed or child records are created/modified. Assume that a ...


49

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 ...


45

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, ...


17

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();...


17

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 ...


15

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

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 ...


14

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

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


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

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 ...


12

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\'');


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....


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

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

Salesforce Ids can be sequential at times but it isn't guaranteed -- so not something you should bank on for sorting. They aren't like, say, MongoDB Ids. Here is a blurb from the Apex Testing Best Practices that makes it official: Record IDs are not created in ascending order unless you insert multiple records with the same request. For example, if you ...


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 ...


9

If you only have the key prefix you can pad it out with the empty id string: String emptyId = '000000000000AAA'; String prefix = '00D'; ID myId = prefix + emptyId; System.debug(myID.getSObjectType().getDescribe().getName()); https://vffiddle.herokuapp.com/415/11


9

The reason why so few people complain about that feature not working is because there are more important features that don't work. Here's a common set of complaints: Auto-completion is hit and miss, can freeze the IDE. Auto-indenting is awful, usually making a mess. Can't organize members. Can't block un-indent. Fewer useful warnings, like a missing "...


9

You can't insert multiple rows in a single call in the rest api, you need to use the bulk api. You can develop custom REST wrapper webservice through APEX language of sfdc to get this set up @RestResource(urlMapping='/insertcontact/*') global with sharing class Mycontacts{ @HttpPost global static List<Contact> doPost(List<Contact> lstcnts){...


9

Java version: public class SalesforceIDConverter { public static String convertID(String id) { if(id.length() == 18) return id; String suffix = ""; for(int i=0;i<3;i++){ Integer flags = 0; for(int j=0;j<5;j++){ String c = id.substring(i*5+j,i*5+j+1); if(c....


9

This is a pretty common approach on small instances (and some large ones too). I usually name the user "Integration User"; some orgs call it "System" or something like that. It's useful to have this user on a profile with API Only set, and no password expiration. If you do have to reset the password, you'll have to reconfigure those ...


9

Both String and Id are primitive data types in apex. Consider below scenario: public class poc { static List<Id> ids = new List<Id>(); public static void check() { try { ids.add('invalid_id'); System.debug('ids => '+ids); } catch(Exception ex) { System.debug('ERROR => '+ex....


9

The answer is NO A far better practice is to store API names in custom settings/custom metadata and query for the resource by apiName in the code: API Names are more transparent than IDs Custom metadata values can be deployed Sandboxes created from PROD that include ID values might be broken if the IDs point at data records not present in the sandbox (such ...


8

There is no way to get Id for a custom or standard field except it you can retrieve name, label type, attributes etc.. The only help can be made is custom field id start from prefix 00N and in production CF appended to 00N In addition there is a idea for which you can vote. Conclusion: getDescribe() don't support id for field.


8

First off, you should create an integration only user if you haven't already done so. This allows you to control security (or open up access) for the middleware integration. Typically I set the integration user's profile settings so that its password never expires, but it is not absolutely necessary. Second, you have two different WSDL's you can choose ...


8

PutAll only works on the ID field of an SObject. It is syntatic sugar for: for(SObject record: someList) someMap.put(record.Id, record); To use any other type of mapping, you would have to make your own for loop. Such a for loop would look like: Map<Id, Contract[0]> someMap = new Map<id, contract[0]>(); ... load account ids here ... for(...


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