Browse Month: April 2015

Creating Custom Apex REST APIs with Force.com

Suppose we want to expose Opportunity object through Rest Web Service.

Step 1 : Create a class like below

@RestResource(urlMapping=’/FieldOpportunity/*’)
global with sharing class RESTOppController
{
@HttpGet
global static List<Opportunity> getOpenOpportunities()
{
String OpportunityName = RestContext.request.params.get(‘OpportunityName’);
Opportunity opp = [ Select ID, Name, Amount from Opportunity where Name = :OpportunityName];
List<Opportunity> OppList = [SELECT Id, CloseDate,StageName, Type,  LeadSource from Opportunity WHERE Name =: Opp.Name];
return OppList;
}
}

Step 2: Create Force.com sites. It  enable you to create public websites and applications. Under App Setup expand Develop and click Sites.

Step 3: Choose a Force.com domain name. Ensure it is available, click the checkbox, then click Register My Force.com Domain.

Step 4: Once your site is registered click the New button.

Step 5:    Give yourself a Site LabelSite Name, and choose an Active Site Home Page. Since no one will use this site as a website I’ve chosen FileNotFound. Click the Save button.

Step 6: By default the site is not active. Click the Activate button or else you will not be able to access your APIs.

Step 7: Next we have to grant anonymous access to our Apex REST API. Click thePublic Access Settings button.

Step 8: Scroll down the Standard Object Permissions and check all checkbox of Opportunity and click on Save button.

Step 9: Scroll down to Enabled Apex Class Access and click the Edit button. Select the RESTOppController and click the Add button. Click Save.

Step 10: Get the url from your site that you have created and put that url to the url bar of your brouser. The url looks like https://yoursitename-developer-edition.ap2.force.com/services/apexrest/FieldOpportunity?OpportunityName=opp_name_that_available_inYour_Org

Extreme Salesforce Integration Onsite

It was my Birthday when I got the news that I m going Onsite, that too USA, ,on 18th April 2015. I was very thrilled and excited for receiving such an awesome gift from my company Nanostuffs Technology Pvt.Ltd.

IMG_20150426_215754                          IMG_20150510_164307

I was going to Bethesda, Maryland. A quiet and peaceful city with population of about 60,000 plus. I was going in a plane for the first time so that experience was also very memorable.The journey was very good with a stop at Doha airport in Qatar.

Once I reached Washington DC airport I had butterflies in my stomach. As opposed to my expectation everything went very smooth and i was out of the airport in very short time. The client for which I was going to work with was very helpful and fun to work with. My accommodation and everything was arranged before my arrival.  There was spring season when I reached USA so everything was colorful around me. The experience of working and living in American Culture was amazing and new for me.

Thanks Nanostuffs for making my Dream come true.

IMG_20150510_151538                 IMG_20150426_185138

Error with memcached in wordpress on windows localhost.

I was trying to setup my wordpress website, www.nanostuffs.com, on windows localhost & had really tough time solving memcache related issues. After 2 days of efforts, finally here is perfect solution:

1. Verify your PHP version matches the one which was for your live site. In my case, it was 5.3.x on live site but had 5.6 on my latest xampp local server. So I installed installed earlier version of xampp that supported PHP 5.3.x

 

2. Install memcache on Windows:

– Follow these steps properlyh http://stackoverflow.com/questions/3016656/how-to-enable-memcace-in-wamp

– Note the php_memcached.dll should match your PHP version, so download the right one from here https://pecl.php.net/package/memcache/3.0.8/windows

– The .exe files that you’ll run from above link (even command prompt) run them as administrator.

– To confirm you did all of it correctly, open Task Manager -> Services -> memcached Server should be running.

 

3. In WAMP or XAMPP, copy the php_memcached.dll file to C:xamppphpext folder if you havent done already.

4. Open php.ini & add extension=php_memcached.dll

5. Stop & restart WAMP or XAMPP, it should start properly without any error shown for memcache. In Wamp, verify the extention is coming without any exclamation mark.

 

6. MOST Important Step:

– Open your wp-config.php file

– Search for $memcached_servers & if it mentions like this:

$memcached_servers=array ( ‘default’ =>  array ( 0 => ‘unix:///tmp/memcached.sock’, ), );

Make it

$memcached_servers=array ( ‘default’ =>  array ( 0 => ‘127.0.0.1:11211’, ), );

 

7. Run your WordPress site & it should not show the memcache error now.

 

Hope this helped saved your time & frustration.