Showing posts with label salesforce. Show all posts
Showing posts with label salesforce. Show all posts

Sunday, March 11, 2012

Getting Salesforce Data from External App

Salesforce encourages developers to authenticate using OAuth.

However, if you are creating a windows service to get data from SF, you'll need to choose the username/password flow.
https://ap1.salesforce.com/help/doc/en/remoteaccess_oauth_username_password_flow.htm

The Steps include:
1) Add new application via Setup -> Develop -> Remote Access
Under this method, the callback URL will not be used.

2) Perform a POST request
To get the authentication token:


https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3MVG9lKcPoNINVBIPJjdw1J9LLM82Hn
FVVX19KY1uA5mu0QqEWhqKpoW3svG3XHrXDiCQjK1mdgAvhCscA9GE&client_secret=1955279925675241571&username=username@salesforceInstance.com&password=SFpassword

3) Parse return JSON and get access_token

{"id":"https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
"issued_at":"1278448832702","instance_url":"https://na1.salesforce.com",
"signature":"0CmxinZir53Yex7nE0TD+zMpvIWYGb/bdJh6XfOH6EQ=","access_token":
"00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW1
9ye6PE3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs"}

4) Perform a GET request

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/0019000000B8JxR?fields=AccountNumber,BillingPostalCode

User-Agent: Fiddler
Authorization: OAuth  access_token
Host: ap1.salesforce.com

Monday, February 27, 2012

Salesforce Converting 15digits ID to 18 digits ID via Formula

Sometimes you'll need to convert the 15 digits ID to 18 digits for external programs to compare IDs.


ExistingFifteenDigitsId 
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",( 
IF(FIND(MID(audit_survey__r.audit__r.Id,1,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,2,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,3,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,4,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,5,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0) 
)+1,1) 
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",( 
IF(FIND(MID(audit_survey__r.audit__r.Id,6,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,7,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,8,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,9,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,10,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0) 
)+1,1) 
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",( 
IF(FIND(MID(audit_survey__r.audit__r.Id,11,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,12,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,13,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,14,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0) 
+IF(FIND(MID(audit_survey__r.audit__r.Id,15,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0) 
)+1,1)

Tuesday, August 30, 2011

Quickly Selecting Data from Salesforce Using System Log

If you just want to quickly see some data in your salesforce instance, you can execute soql queries by opening the Setup-> "System Log" and type in the following

System.debug ( [select Dealer_group_display__c from Account where Id = '001M0000005OFab']);
System.debug( UserInfo.getSessionId() );

This saves you from opening the Apex dataloader.

Wednesday, May 18, 2011

DreamFactory migration steps

The following is just one way to migration an installation (ie OpenWealth).

1) Install package onto the new site
2) Use Monarch to migrate data across
3) Migrate page layout

Salesforce Migration Order/Best Practices

A snippet from Dream Factory's Snapshot documentation:

In order to achieve maximum results with your deployment, it is recommended that you follow the documented order of operations that is detailed below for Asset SnapShot Push. This order will minimize the errors generated by contingent dependencies and relationships in your Org. Carefully read any error messages and make adjustments as necessary. If you need to be able to push individual object fields then use the Object SnapShot Push.

1.    Objects: All *
2.    Apex Classes
3.    Apex Components
4.    Apex Pages
5.    Apex Triggers
6.    S-Controls
7.    Page Layouts
8.    Static Resources
9.    Letterheads
10.    Workflows **
11.    Report Types
12.    Home Page Web Links
13.    Home Page Components
14.    Home Page Layouts
15.    Custom Tabs
16.    Custom Labels
17.    Custom Applications
18.    Custom Object Translation
19.    Custom Sites
20.    Profiles: All ***
   
   
* This will push all Object fields plus their related Record Types, Web Links, Validation Rules, Search Layouts and List Views. These settings can also be pushed individually if needed.

** Users tied to workflows must be created in the Destination Org prior to pushing

*** This will push all Profile metadata plus the related settings including: Application Visibility, Field Level Security, Layout Assignments, Object Permissions, Record Type Visibility and Tab Visibility. These settings can also be pushed individually if needed.

Sunday, April 10, 2011

SalesForce Admin ADM 201

Test Concepts in Admin ADM 201

-Different types of relationships for custom objects
-If you want to disable viewing all objects in an application, where do you set this?
-If the system wide default is read/write, how can you restrict what records the user can view?
-what will happen to the existing exchange rates will you turn on advance currency management
-mass transfer of user's records (one of the following will not be mass transferred: open case, close case, open activity, closed activity)