Make a HTTP Request in Salesforce

We can make http request in salesforce. We must define a remote site of it before making a http request.

Add site in remote site setting :
Go in the Setup Menu -->Administer ---> Remote Site Settings ---> Add here your site setting

String payLoad = 'some_data=value+1&some_more_data=value+2&etc_etc';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://www.contoso.com/');
req.setMethod('POST');
req.setBody(payLoad);
HttpResponse res = h.send(req);

system.debug(‘Response :’+res.getBody());

Test User Creation In Salesforce

Account accObj = new Account();
accObj.name='test';
insert accObj;

contact con = new contact();
con.firstname = 'test';
con.lastname = 'test';
con.Email = 'test@test.com';
con.AccountId = accObj.id;
insert con;

Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = false;
User u = new User(alias = 'standt', email=con.email,
emailencodingkey='UTF-8', lastname=con.lastname,
firstname=con.firstname, languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, contactId=con.Id,
timezonesidkey='America/Los_Angeles',
username=con.email);
u.setOptions(dmo);
insert u;
System.runAs(u) {

}

Multiple File Uploading in Salesforce

We can able to upload multiple files at a time.
On the page we define the id of record in which the all attachments will be saved/attached. You can also customize the code as you want.

Click here to get code from my developer org ...

You can see more about it from tehnrd.

Salesforce Offline Connect

Help Links :
1 : Installing Connect Offline
2 : What is Your Default Connect Offline Briefcase Contents?
3 : Logging in to Connect Offline
4 : Working with Connect Offline
========================================
Where/Why we use ? :
Suppose that a company ABC have lots of trucks for transportation.Company needs that whenever truck driver delivers these stuffs, they shoud to be update status of things.
Problem is that many times drivers have no net. So in this case we can use connect offline to update status at offline . Whenever they catch net , data will sync with cloud.
========================================
Steps to make possible :
1. Click on User name ==> My Settings ==> Expand Personal in side bar ==> Click on Advance User Details ==> check the Offline User

2. Click on Setup ==> Desktop Administration ==> Offline Briefcase Configurations 

=: Create new Offline Briefcase Configuration after this create dataset in this briefcase

3. Download Software : Click on User name ==> My Settings ==> Expand Desktop Add Ons in side bar ==> Click on force.Com Offline Connect ==> Install Now


4. After the software instalation open the SW and fill username and check all the check all the check boxes only first time.


5. Go offline and click open SW again , login without check the any checkbox .It will open a browser within salesforce offline.

======================================
Some tricks must be follow before run SW :
If you have windows 8 or 8.1 then we need to change compatibility of software.
Right Click on SW ==> compatibility Tab ==> Set to Windows Xp 3
======================================
Note : Offline Connect Works in only IE 6,7,8 only.

Extract Image from RTF (Rich Text Area) Salesforce

String ​imgPath = String.valueOf(<RTF filed>);
imgPath = imgPath.subString( (imgPath.indexof('src')+5),imgPath.indexof('"',imgPath.indexof('src')+5));

Exp : String ​imgPath = String.valueOf(accObj.nyRtf__c);
imgPath = imgPath.subString( (imgPath.indexof('src')+5),imgPath.indexof('"',imgPath.indexof('src')+5));

Get Relationship Name between Parent And Child Object Salesforce

String parentObj = 'Account';
String childObj = 'Contact';

Map<String,Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(childObj).getDescribe().fields.getMap();

for(Schema.SObjectField f:fieldMap.values()){
   String type = String.valueOf(f.getDescribe().getReferenceTo());
   if(type.contains(parentObj)){
       system.debug('Field Name:- ' + f.getDescribe().getName());
   }
}

You Tube Integration with salesforce

You need a google api key for access data from youtube.
Steps to create api key :
1. Go here : https://console.developers.google.com/project 
2. Click on Create Project, put name of project then Create (Wait)
3. Go on -->Api & Outh ---> Credentials
4. Click on Create New Key
5. Select Server Key
6. Now Copy The Api Key and put in code ( private static final String API_KEY = ''; )

Click here to get code from my developer org ...