Posts

Showing posts from 2015

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

HTTP to HTTPS redirect on IIS

Image
The requirement was simple. To redirect all HTTP traffic to HTTPS traffic. First thought that crossed my mind is - "Can't we do it with HTTP redirect ?". After trying the approach, the site went into a infinite redirect loop. Pretty obvious! Right? After some googling, this is what I have done.  Install URL Rewrite module from   http://www.iis.net/downloads/microsoft/url-rewrite Add the following rule to your web.config. For more details about, doing the same from UI is explained @  http://www.jppinto.com/2010/03/automatically-redirect-http-requests-to-https-on-iis7-using-url-rewrite-2-0/ < rule name = "Redirect to HTTPS" stopProcessing = "true" > < match url = "(.*)" /> < conditions >< add input = "{HTTPS}" pattern = "^OFF$" /> </ conditions > < action type = "Redirect" url = " https:// {HTTP_HOST}/{R:1}" redirectType = "SeeOther"

HockeyApp Cordova Plugin

I have improved the HockeyApp plugin for iOS and Android.  You can find all the code and documentation @ https://github.com/pradeepkumargali/cordova-plugin-hockeyapp  My Additions: Latest Hockey API Easier installation via command line New Feedback feature Please report any issues on github. Happy Coding!

Disable telephone detectors in Safari/Hybrid app (x-apple-data=detectors)

Image
Problem:  You see an unexpected hyperlink against numbers in your text.  Solution: Include the following in your landing html page at the top. <meta name="format-detection" content="telephone=no">  Reference: http://stackoverflow.com/questions/2106102/disabling-data-detectors-for-a-specific-html-element-in-a-uiwebview http://stackoverflow.com/questions/10655815/disable-telephone-anchor

Hosting A Static Website In Google App Engine - Eclipse, Java

A few months ago, I played around with Google app engine. Somebody asked to set up a personal website which is nothing but a collection of static pages, images and JS widget to do a carousel/gallery. I tried my hand at Google app engine. In another instance, I hosted Google Course Builder on app engine. In both instance, my experience is smooth. Used Google app engine launcher.  Configured .yaml file (Replace application name with the unique application name you set up on google.)What if you want to setup your site using Java on AppEngine. Generally, java developers start with Eclipse. Generally, we follow the tutorial by Google.  https://cloud.google.com/appengine/docs/java/gettingstarted/introduction The question is how to put our static files on AppEngine and point index.html as the startup page. Answer - include static file location to app-webengine.xml.  In this case I created "static" folder under war folder. Also, set the expiration date. Using this setting, serve

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

Sticky horizontal bar on Mac

Image
Problem: I encountered a sticky horizontal bar, after a failed or incomplete download. Please see the pic below. Horizontal Line on Doc Solution: run killall Dock References: http://apple.stackexchange.com/questions/159541/what-is-this-line-on-my-dock 

Salesforce OAuth 2.0 "authorize" endpoint doesn't return refresh token

Problem: Salesforce OAuth 2.0 "authorize" ( https://login.salesforce.com/services/oauth2/authorize)  endpoint doesn't return refresh token Solution: The refresh token for the user-agent flow is only issued under one of the following circumstances: The redirect URL uses a custom protocol. The redirect URL is exactly  https://login.salesforce.com/services/oauth2/success , or on Sandbox,  https://test.salesforce.com/services/oauth2/success . The redirect URL uses the http protocol and the host is localhost - e.g.  http://localhost:8080/ References: http://salesforce.stackexchange.com/questions/7554/oauth-api-doesnt-send-refresh-token-with-custom-redirect-uri  https://help.salesforce.com/apex/HTViewHelpDoc?id=remoteaccess_authenticate.htm&language=en_US