metadaddy
  • Member for 9 years, 5 months
  • Last seen this week
Differences between OAuth Web Server Flow, User-Agent Flow, Username-Password Flow?
Accepted answer
43 votes

Web server flow (In OAuth spec terms, Authorization Code Grant) tends to be used for web applications where server-side code needs to interact with Force.com APIs on the user's behalf, for example ...

View answer
How should I build test methods for Visualforce Controller Extensions
Accepted answer
43 votes

The following code will test that you are correctly saving the account record in the constructor (which is all your extension does so far): public static testMethod void testmyExtension() { ...

View answer
How can I return JSON object from REST service?
Accepted answer
32 votes

If you have a JSON object as a String, you can return it by assigning it to the responseBody, like this: @RestResource(urlMapping='/MyService/*') global class MyService { @HttpGet global ...

View answer
Connected App - avoiding a limit on a number of issued tokens + token expiration
Accepted answer
27 votes

I see you've discovered most of this for yourself, but I had this drafted, so I thought I'd post it also, in case it fills in any gaps. From the docs on connected apps: An application may be ...

View answer
Mimic MySQL AES_ENCRYPT in Apex
Accepted answer
25 votes

UPDATE: Apex is still not the best tool for byte-twiddling, but the addition of EncodingUtil.ConvertFromHex() in Spring '14 makes this MUCH easier. Here's a better version of my implementation: ...

View answer
Use Salesforce1 mobile app to access camera
Accepted answer
25 votes

You can access the camera from a Salesforce1 app, using the HTML <input> tag with accept="image/*" to access either the camera or photo library, for example <input id="photoFile" type="file" ...

View answer
Salesforce: Any API for getting user information?
Accepted answer
25 votes

Assuming you've done OAuth, the OAuth response includes an id field with an Identity Service URL - e.g.: { "id":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ", "...

View answer
Is there a way to make the insert not fail if one record fails?
Accepted answer
23 votes

Use a DML database method with a value of false for the optional opt_allOrNone parameter - i.e. Database.SaveResult[] result = Database.Insert(accounts, false); From the docs, Use DML database ...

View answer
How does Delegated Authentication and Federated authentication work in parallel?
Accepted answer
21 votes

When an HTTP request arrives at Salesforce, if there is no valid session ID supplied (or the request is for a login page), Salesforce first examines the requested domain. If the requested domain is a ...

View answer
How do I use Type.forName to deserialize a generic list of SObjects?
Accepted answer
19 votes

The trick is to deserialize into a List<SObject>. This works for me: String jsonString = '[{"Name":"A1"},{"Name":"A2"}]'; Type t = Type.forName('List<Account>'); List<SObject> lo = (...

View answer
Help me solve a concurrency mystery (platform bug? Expected behavior? Or am I missing something?)
18 votes

I believe SELECT ... FOR UPDATE does indeed do a write lock, as implied by the docs: Apex allows you to lock sObject records while they’re being updated in order to prevent race conditions and ...

View answer
How do I use the Tooling API to create a new Apex Trigger?
Accepted answer
17 votes

It turns out that https://[instance].salesforce.com/services/data/v27.0/tooling/sobjects/ApexClass is a special case, and, in the general case (ApexComponent, ApexPage, ApexTrigger) you use the ...

View answer
JSON String in response shows up with quotes
16 votes

To return a string without the quotes, set it as the response body: @HttpGet global static void sayHello() { RestContext.response.addHeader('Content-Type', 'application/json'); // Return a ...

View answer
screen scrape Salesforce with REST GET call from Apex
Accepted answer
15 votes

Please don't screen-scrape - it's just about the most fragile integration you can imagine. With the release of the Analytics API, it's also now largely unnecessary Having said that, the Authorization ...

View answer
How is it that some OAuth-authenticated apps don't require an Org to create a Connect App in order to be installed?
Accepted answer
15 votes

In every case, as the app developer, you create a Connected App, obtaining a consumer key and secret for that app. Now users can use your app in any org. That's right - you don't need to create a ...

View answer
Salesforce Integration + Streaming API
Accepted answer
15 votes

Word direct from the API PM: We have customers doing thousands of clients… one customer is going to do 150K clients. Folks just need to ping us for an increase request. We like to rollout ...

View answer
How to create a lead from an email?
15 votes

One of the packaged apps mentioned in other answers may well be the easiest option, but it's pretty straightforward to create an Email Service in Apex. The sample code in the docs creates a Contact ...

View answer
When do Sessions expire?
Accepted answer
14 votes

Sessions expire after the specified amount of idle time (see below), rather than an absolute time period. So, assuming your session timeout is at least an hour, you will keep it active by making a ...

View answer
My Domain and API endpoints
Accepted answer
14 votes

Enabling My Domain is additive - your existing endpoints will continue to work - you can use either na1.salesforce.com or mynewname.my.salesforce.com in API endpoints just fine. Having said that, ...

View answer
Display PDF with Visualforce
Accepted answer
14 votes

You can embed a PDF in a Visualforce (or any other HTML) page via a data URI. Using your example, the code would be something like: <apex:page controller="DownloadPDF" sidebar="false" showHeader="...

View answer
How to Print/Export the schema builder?
Accepted answer
14 votes

Print/export from Schema Builder is not currently possible, but you can go vote on the idea for a future release. There is, however, ERD Tool, a free app in the AppExchange that might work for you.

View answer
Eclipse/Force.com IDE not displaying errors in Problems pane - Summer 14 sandbox
13 votes

There are a couple of issues in Summer '14 that are causing pain with the Metadata API: The checkDeployStatus() API call does not return deploy messages for API versions 28.0 and below. See known ...

View answer
OAuth2 token request using JSON fails - grant type not supported
Accepted answer
13 votes

Salesforce doesn't support JSON in the access token request; the OAuth 2.0 spec mandates application/x-www-form-urlencoded.

View answer
Read timeout error calling a third party REST API
Accepted answer
13 votes

Yes, you can catch the CalloutException; from the Apex Web Services and Callouts wiki article: try { //Execute web service call here HTTPResponse res = http.send(req); //Helpful ...

View answer
Compile Error: Comparison arguments must be compatible types
Accepted answer
13 votes

The line provoking the error is actually System.assert(e.getDmlFields(0)[0] == 'Email'); The error is complaining that you're comparing a Schema.SObjectField value with a String, which isn't allowed....

View answer
Workarounds for Missing Apex Time.format() Instance Method
Accepted answer
13 votes

You could just split the DateTime format() result on the first space - does that give you what you're looking for? public String myDateFormat(DateTime dt) { String[] parts = dt.format().split(' ')...

View answer
Customer Community login using REST API
Accepted answer
12 votes

Since community usernames are not globally unique, you need to use SOAP login with LoginScopeHeader to identify the org: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-...

View answer
Salesforce Canvas cross-domain issue
Accepted answer
12 votes

This is a long answer that attempts to explain exactly what's going on here, and how HTML5 and the Force.com Canvas SDK allow safe cross-origin access. It may be that your issue has no solution, but ...

View answer
Is it possible to use Facebook SSO with portal users?
12 votes

You can use it with a portal (see step 11 in the documentation). The user's Facebook ID is associated with their Salesforce user record. You receive their name and email in the registration handler ...

View answer
check if sessionid is valid
Accepted answer
12 votes

As joshbirk mentioned in another answer, OAuth is the preferred mechanism for authenticating users. The refresh token gives you a persistent value you can save (securely - treat it like a password!) ...

View answer
1
2 3 4 5
9