Posts

Showing posts with the label Salesforce

Upgrading Salesforce SDK App to Android Studio

As some of you would have noticed, there is no easy way to integrate the project created/upgraded using "forcedroid" into Android Studio. After some struggle, I followed below steps to acheive this.  1. Make sure you are on the right Cordova version. As of Salesforce Mobile SDK 3.3, Cordova 3.6.4 is supported. If you have Cordova 4, you have target your platform  Cordova platform add android@3.6.4 To check the current version use - cordova platform  2. If you have made earlier attempts, please remove all references to gradle and studio project settings.   rm -r .idea find . -name "*.gradle" -type f -delete find . -name "*.iml" -type f -delete 3. Also, remove any intermediate builds generated. I cleared the build folder using  rm -r build 4. Now to make sure all the references correctly placed, open the project in Ecclipse and check if the build is working properly.  5. Now open import the project into android studio Open a N

Generate token signing .CER from ADFS Federation Metadata XML

Image
While workging on Force.com SSO, our ADFS team has provided me with federation metadata xml only. As per this link , you also need a token-signing certificate from provider to complete the setup and provide the Force.com XML file to ADFS. Now, the question is how to generate .pem/.cer file out of FederationMetadata.xml file.  Edit FederationMetadata.xml file, and search for  <KeyDescriptor use="signing">. You should find more than one entry. Pick any one of them.      2.  Pick the X500Certificate value and save the text as .der file     3.  openssl x509 -in <(base64 --decode FILE_FROM_STEP2.der) -inform DER -out OUTPUT.pem Use <OUTPUT>.per as Identity Provider Certificate.  Reference:  https://ask.auth0.com/t/how-to-convert-saml-federationmetadata-xml-key-to-pem-or-cer/24

Get Complete Package.xml

Below are a few interesting post about preparing package.xml automatically. https://github.com/JitendraZaa/AutoGenerate_Package.xml_Ant http://www.tquila.com/blog/2014/02/11/salesforce-packagexml-builder https://packagebuilder.herokuapp.com/ There is no way to figure out wild card metadata components (*) using API. Also, there is no way to figure out what components are not supported as part of force.com migration tool.  Out of above posts, I found Jitendra's post very interesting and useful. Whereas packagebuilder by Tquila guys, generates an exhaustive list of package.xml file for your organization.  On a side note Tquila guys have build a few interesting heroku apps.  https://sfswitch.herokuapp.com/  - To switch components between orgs.  sforgcompare.herokuapp.com    - To compare metadata between orgs. Watch this space for more info!

Performance tuning of a visualforce page

Image
It's my strong belief that a developer should always keep the performance in the top of the priority list. As I was working on a big Visualforce page with lot of aggregations, I wondered how to get best performance out of APEX and VF.  I went through  Apex Code Best Practices  and  salesforce_visualforce_best_practices.pdf .  Both were really helpful, until I ran into following statements.  Apex Best Practice # 4 states " Use the power of the SOQL  where  clause to query all data needed in a single query. "   Visualforce guide states " When writing Apex or SOQL for use with a Visualforce page:  • Perform calculations in SOQL instead of in Apex, whenever possible. • Never perform DML inside a loop.  • Filter in SOQL first, then in Apex, and finally in Visualforce " Now, I am confused on writing a single SOQL and do the aggregations such as (max,min, sum, avg) in APEX or writing multiple aggregate SOQL's relay the data to VF thr

Mobile SDK Upgrade From 2.3 to 3.0

Image
Compilation and Linking Issues Upgrading Salesforce Mobile SDK from 3.1 to 3.2 is indeed quite simple $ cd < your_Cordova_app_folder > $ cordova plugin rm com.salesforce $ cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin $ cordova prepare But every time I did the upgrade from 3.x to latest version of SDK. I see the following set of errors. Undefined symbols for architecture arm64:   "_OBJC_CLASS_$_SFHybridViewController", referenced from:       objc-class-ref in AppDelegate+SalesforceHybridSDK.o   "_OBJC_CLASS_$_SFDefaultUserManagementViewController", referenced from:       objc-class-ref in AppDelegate+SalesforceHybridSDK.o   "_OBJC_CLASS_$_SFUserAccountManager", referenced from:       objc-class-ref in AppDelegate+SalesforceHybridSDK.o   "_OBJC_CLASS_$_SFLogger", referenced from:       objc-class-ref in AppDelegate+SalesforceHybridSDK.o   "_OBJC_CLASS_$_S

Sample code to upload a file to chatter feed using REST API

Image
Step 1: Download required files Download the following files from internet httpcomponents-client-4.2.3-bin.zip org.apache.commons.httpclient.jar From the files, I have added following JARS to my project in eclipse.    Screenshot from Ecclipse Step 2: Get Access Token Through Chrome Login to your Salesforce instance and navigate to Setup -> Create -> Apps.  Create a custom app and fill Client ID and CallBack URL (ex: http://www.google.com) in the following URL. Encode the CallBack URL before passing it as a parameter.  https:// <instance_name> .salesforce.com/services/oauth2/authorize?response_type=token&client_id= <Client_ID_Goes_Here> &redirect_uri= <CallBack_URL> Paste this URL in chrome In Developer Tool -> Network select "preserve log upon navigation" Load the page. We see below page. The page will take us to RemoteAccessAuthorizationPage.apexp which inturn will lead us to  _ui/i

How Get $Site.CurrentSiteUrl in formula editor

If we want to see the current site url in HYPERLINK function of formula editor, this is how it should be done.  LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260)) Reference:  http://salesforce.stackexchange.com/questions/3816/how-do-i-get-the-base-url-in-the-formula-editor

Chatter Unfollow Test Class Failures

Recently, we noticed all test failures in one of our test classes. The test class was written in 19.0. The problem being SOQL's were not returning records and all the assertions were failing.  Assertion Failed: Expected: 2, Actual: 0 The fix turned out to be very simple. We fixed the error by updating the APEX class version to 29.0

Android SalesforceSDK - Make Mobile Layout More Responsive By Using Load Spinner

Image
I noticed that layout-xlarge in Android Salesforce SDK has a nice loading spinner and header bar. So I have changed the layout appropriately. As part of this effort, I have modified or copied drawables,colors etc. from xlarge  resources. There are no code changes required. I am attaching the resources folder for the same. Replace the res @  ....forcedroid\native\SalesforceSDK  with the contents of the following zip https://docs.google.com/file/d/0BwilPq-bDpVPM1pyMGFiMy1WSUk/edit?usp=sharing  

Native Vs Hybrid

There are three ways to deliver an application on Mobiles – 1. Native – Built on Native Mobile Platform 2. HTML 5 – Works in browser 3. Hybrid – Built with HTML5, Can access native features It is clear that user spend 80% of their time using Apps on mobile. That is four times more than the time they spend in browsing. Hence, browser based HTML 5 application is not the preferred way to deliver your mobile application. We have two options left before us. One, build a native application using the mobile OS platform (ex: Android or iOS). Second, use your HTML5 skills to quickly build an application and make it work as a native app on all platform using build frameworks such as PhoneGap. Many have tried to compare and contrast Native and Hybrid. In this article I will summarize the analysis I have done over this subject matter.  After going through lot of articles and presentations, a presentation from propelics appealed to me. It is unbiased and to the point. Below are the pro