Pages

Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Friday, November 22, 2013

Dreamforce 2013 Developer Keynote Highlights

Just finished watching the developer keynote from this years dreamforce..

here are some of the key highlights that i noted down from this hour long video..

Force.com Command Line Interface (CLI)
its an open source tool to help developers access the salesforce instance and all of the objects (standard, custom), run soql queries, import & export of metadata, etc..

Introduction
http://blogs.developerforce.com/developer-relations/2013/11/announcing-the-command-line-interface-for-force-com.html

Some more details
http://www.wadewegner.com/2013/11/a-command-line-interface-for-forcecom/

source code and setup
https://github.com/heroku/force

API.. API.. API.. API...
one of the buzzword througout this dreamforce is API.. most of the stuff in salesforce platform is now API enabled.. this will be the base for cross platform, device independent, application development.
since most of the integration with API's happens over http, xml & json, there are not client libraries to ease the integration. couple of libraries highlighted are

Ruby Client for REST api
https://github.com/ejholmes/restforce

Node.js REST api wrapper for force.com
https://github.com/kevinohara80/nforce

d3.js - to visualise & chart the data from analytics api
http://d3js.org/
example - https://medium.com/p/c87517ab52b1

Salesforce1
This is probably the biggest anouncement for developers this year... its a complete rebranding and futurisitc strategy to put the force.com platform as mobile first & api driven.. this is an umbreall of force.com, heroku and exact target and other supporting components put together. we now have a new developer site for the salesforce1 platform.. which has a good collection of documentation & other resources around the platform and api's..
http://developer.salesforce.com/

Mobile packs and Mobile SDK
these are already released in phases over the period and got a special mention in the keynote to hightlight how it fits in the Salesforce1 platform. the mobile packs covers the development with existing client side web technologies like HTML5 with javascript libraries like Angular, Knockout, jQuery, etc.. and the Mobile SDK covers the iOS and Android based development

Heroku Connect
if you have any of your apps running in heroku and interfaces with salesforce, then this will be a handy app to sync the data between your postgres database and salesforce data. you can create mapping between these 2 databases and enable syncing (uni directional or bi directional)

you can try heroku connect by logging in here
https://app.cloudconnect.com/

you can find more details on this here
https://blog.heroku.com/archives/2013/11/19/tools-for-integrating-heroku-apps-with-salesforce

Demo Time
some of the cool stuff shown in the demo in keynote are

  • Mobile Cards in page layouts
  • creating a simple chart with analytics api, add it to object page layout, show it in mobile devices
  • Enhanced Lookups in page layouts
  • Flexi pages
  • creating Quick actions (publisher actions) and using it in Salesforce1 mobile app

Finaly you can watch the developer keynote video here
http://www.youtube.com/watch?v=KELBWQIVcfk

will try to cover more on the Salesforce1 platform in future blog posts.. lets learn this together :-)

Monday, November 18, 2013

Salesforce1 and SalesforceA apps (iPhone,iPad,Android) initial look and review

Salesforce1
I recently updated Salesforce1 app in my iPad,iPhone and HTCOne Andriod phone and played around with the apps for a while... Here's my initial feedback on it..

For beginners, note
  • Salesforce1 is not a new app.. Its an upgrade of an existing app "Salesforce Chatter Mobile" which was there close to 3 years and got matured over the period..
  • Salesforce1 is not just a new glossy mobile app... its part of a platform/framework 
  • Its a collection of a set of development tools including our existing force.com tools, emerging mobile sdk, heroku tools, newly aquired ExactTarget stuff,
  • it has lots of focus on API based development, ability to integrate/communicate with any app/platform/device
  • setting up new direction in salesforce app development 

Its too early to write anything on the entire platform.. so i m just focusing on the mobile/tablet app here

So whats new or different from previous apps/versions ..


here's the list of new features listed in the app 

  • Improvised search - ability to search across the feeds including records, people, groups & conversations
  • Make use of publisher actions that you created in your org from any device with this app
  • Custom list views - now you will be able to see your custom list views not just the recently viewed records
  • Access all your objects (standard, custom, apps)
  • notifications pane on the right
  • ability to mobile optimized access appexchange apps 
  • ability to create new records from the list view 

after going thru the listed features, few things that I expected but couldn't find..

  • We cannot edit our own user details (name, photo, etc.. ) - need to use the SalesforceA app for this 
  • Not possible to edit groups even if we own it
  • thou it says we can access apps and objects, I found only objects. - to get additional stuff we need the customize the navigation menu by logging into the desktop site and changing the settings under Setup ->  Administration -> Mobile Administration -> Mobile Navigation.
  • List views are restricted. As usual by default it shows the recently viewed records with option to select custom list views. and just below recently viewed, you will see the custom list view names.
  • The custom list views shows the records in "Google Now" style mini post cards - but we cant change the number of records showing up, what fields to display on the cards, the sort order, etc..
  • When the navigation pane is opened, you cannot scroll thru the main pane.. It jus freezes..
SalesforceA
This app is an admin friendly app that goes along with Salesforce1 app - 

  • primarily to manage users 
  • edit, unlock, freeze, deactivate user accounts
  • reset passwords
  • manage permission sets
We have a Rocket Launcher at the bottom of this app.. that takes us to the community page of ideas, answers, events, user groups .. not sure what the actual intent is but its adds a fun/game element to the app..

Rest of the Apps
So what happens to Salesforce Classic, Salesforce Touch, old version of Chatter Mobile... not sure.. need to wait and watch

Bottom Line
I can see the direction of getting into a unified app experience with the vision of customer engagement and better experience which is good... but the current set of multiple apps from salesforce to do different things is a killer..

Monday, August 05, 2013

apex pageblocktable, commandlink, commandbutton, actionRegion, actionStatus, actionFunction, param

here is my recent experience in salesforce visualforce page development...

Requirement 
  • to insert a new section to add/remove items to an order in an existing order entry page... 
  • based on the item price, the order totals, tax, shipping etc. should get updated..

Design
  • item description & price are captured through Input Text fields. 
  • "add item" action triggered when a command button is clicked, 
  • the item description & price are added to the pageblock table along with a "remove" commandlink in the last column. 
  • The totals section is updated to include the item price.
  • "remove" action is triggered when the commandlink is clicked in any of the pageblock table row, the corresponding item is removed. 
  • the totals section is again updated to exclude the removed item price.

Catch
looks simple right, the catch is the recalculation of the totals was already done using javascript. so i need to hook into the existing javascript/jquery functions once the item is added/removed from the pageblock table.

also, the re-rendering of the pageblock table and the totals section is done using ajax.

Code
<apex:pageBlockSection title="Add/Remove Items" columns="1" collapsible="false" rendered="{!(Order.Type == 'CargoItems')}">
<apex:actionRegion immediate="true">
<apex:actionStatus id="updateTotals" onstart="block('{!$Component.MainForm}');" onstop="recalcTotals(); unblock('{!$Component.MainForm}');" />
<apex:actionFunction name="addItems" action="{!addCargoItem}" status="updateTotals" reRender="itemsTable"/>
<apex:actionFunction name="removeItems" action="{!removeCargoItem}" status="updateTotals" reRender="itemsTable">
<apex:param name="rowId" value="" />
</apex:actionFunction>
<apex:pageBlockSection columns="3" showHeader="false">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Item Description"></apex:outputLabel>
<apex:inputText value="{!itemDesc}" styleClass="itemFields itemDescField" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Item Price"></apex:outputLabel>
<apex:inputText value="{!itemPrice}" styleClass="itemFields itemPriceField" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:commandButton value="Add Item" onclick="addItemRow(); return false;" >
</apex:commandButton>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageblockTable id="itemsTable" styleClass="itemTable" value="{!CargoItems}" var="cItem" >
<apex:column headerValue="Item Description">
<apex:outputText value="{!cItem.Description}"/>
</apex:column>
<apex:column headerValue="Item Price">
<apex:outputText value="{!cItem.Price}" styleClass="cargoItem" />
</apex:column>
<apex:column headerValue="">
<apex:commandLink value="Remove" onclick="removeItemRow('{!cItem.Id}'); return false;">
</apex:commandLink>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSection>

please be mindful in placing the actionRegion... it should just surround your input value controls that needs to be passed in an ajax request. if you place the pageblocktable inside the apexRegion, then the table rows will not be rendered properly.

Flow
  • "add" commandbutton and "remove" commandlink both calls javascript functions,
  • run any validations in the javascript functions & then call the actionFunctions
  • actionFunctions are tied to the controller methods which adds/removes records to the collection
  • pageblock table is binded to the cargotItems collection in the controller
  • when the call returns back from controller to actionFunction, actionStatus is fired which calls the existing javascript recalculate method to update totals section & also re-renders the pageblock table 


hope this helps someone who has a similar sceanrio...

Thursday, July 25, 2013

Salesforce Force.com IDE Startup Error jvm terminated. exit code=-1

If you are starting Force.com IDE either after a fresh installation or an upgrade,

You might see a scary big popup with this error jvm terminated. exit code=-1. dont runaway.
One of the ways to simply fix it is to open up your force.com config file and remove the unwanted configurations added at the end.

The force.com config file is located in your installation directory. by default it goes into
C:\Program Files\salesforce.com\Force.com IDE\forceide.ini

open up the file using a text editor and comment the configuration keys at the end
(add # at the start of each line)
#-vmargs
#-Dfile.encoding=UTF-8
#-Xms256m
#-Xmx1024m
#-XX:PermSize=128M
#-XX:MaxPermSize=512M

here is the other options to fix the issue
http://stackoverflow.com/questions/11220594/salesforce-ide-starting-error

for me even after updating this, it was still failing with another error  
java.lang.RuntimeException: Application "" could not be found in the registry

to fix this error open up the config file
C:\Program Files\salesforce.com\Force.com IDE\configuration\config.ini

and comment the line
#eclipse.application=


ideally it should have the list of applications. not sure why its blank, so just comment it and force.com ide works perfectly after that... hope this helps some of you


Friday, April 20, 2012

online Javascript formatting

Heck... we had to work on a javascript file that was ages old and the entire logic was put in 1 line..
no one could understand anything out of it until we formatted it to have proper structure... the formatted script showed us the original 1 line script had close to 15 functions and several variables declared in between the functions used across the script..

we know its good practice to keep the script in this minified version in production environment.. but in development space, we need to have a better formatted one always...

the online tool we used to format the script was
http://jsbeautifier.org/

this is really quick, has options to specify how you want the formatted script, delivers the formatted script in clear text, easy to copy & re-use...

just though of sharing this, as we the web developers are trying to reuse scripts from one another and if in case we want to understand or extend the scripts which is non readable, this tool is very handy...



Wednesday, November 09, 2011

my recent client side web development experience...

just wanted to share some of my recent web development experiences...
Requirement
one of my recent project is to rewrite an existing desktop application for internal users and we wanted to go web based this time instead of windows application. Most of the core logic for the old app was in database in the form of complex stored procs, but the existing windows application was also having lot of custom override logic rewritten many times over the past few years which made it run slow and completely block lot of other internal users during its execution time. our task was to increase the performance, remove the locks, redesign the application interface with more flexibility and to simplify the overall process.


Design


Data Layer
as part of the redesign, the first task was to update the database procs with all the additional custom logic moved into them from the client app and kept the client layer very light. literally the client layer is just a view now.
Service Layer
then we added a light weight service layer in between the web client and the database layer. this service layer is to support the ajax calls from the client layer and to do the required data transformation. no business logic again  here.. all the database calls are asynchronous ones taking advantage of the async options avaialble in the ado.net framework
Client Layer
we started building the client interface using html5, css3 and jquery... but then we realised some of our users are still running IE8 or less in Win XP so we can't make the interface to fail.. so we limited ourself to safe use of jQuery & jQuery UI with additional client side UI plugins which runs fine even in old versions of IE.

first we broke down our layout into 5 steps based on the existing logic and the new requirements we gathered from the users, then started building up the interface based on these 5 steps. we wanted to keep the UI as simple as possible, so tried to limit everything in 1 page with no additional navigation, extra tabs, links..


Panels
So we kept all 5 steps in 1 page with each step as a collapsible container. the requirement is to display data @ each step based on the business rule. the users can then select, filter, modify the data in each step and take additional actions on them and process the data into the next step and it continues till step 5. we encapsulated all the controls required for each step into a panel using the jQuery plugin Expandable.
https://github.com/flamewave/jquery-ui-expandable/

Grid
To achieve our goal to display, filter, sort, edit, update the data entirely on the client side we looked around for a client side grid which can bind to the data using ajax calls and manipulate the html data using javascript fast and neat. then we ended up using one of the best available
http://www.datatables.net/

Action
all of the actions that the user perform on the data which needs to submit/retrieve the data and for which calls hops thru service and into data layer, we need to display a confirmation message and block the page till the user confirms. we used the simple blockUI plugin from jQuery
http://jquery.malsup.com/block/

Ajax/Async Calls
we made all of the service calls from the UI ajax based and kept all the database calls from the service layer as Async calls taking advantage of the inbuilt ado.net asynchronous support. this made the user to trigger the calls and get back to the interface as fast as possible without any blocks so that they can carry on with rest of their work. all of the service calls uses JSON data format and the parser we used  is available here
https://github.com/douglascrockford/JSON-js

Final Line
all these plugins used are simple, opensource, jquery based which made our client side web development much easier and faster. and the good part is we were able to make some adjustments and customise some of these plugins based on our needs with very less code change...

happy coding :-) 

Monday, September 12, 2011

HTTP Status Codes

Below is the consolidated list of standard HTTP status codes taken from Wikipedia HTTP Status Code List
1xx - Informational
100 Continue
101 Switching Protocol
102 Processing
103 Checkpoint
122 Request URI too long
2xx - Success
200 OK
201 Created
202 Accepted
203 Non Authoritative info
204 No Content
205 Reset Content
206 Partial Content
207 Multi Status
226 IM Used
3xx - Redirection
300 Multiple Choices
301 Moved Permanently
302 Found
303 See other
304 Not Modified
305 Use Proxy
306 Switch Proxy
307 Temp Redirect
308 Resume Incomplete
4xx - Client Error
400 Bad Request
401 Un Authorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Auth Required
408 Request Timed out
409 Conflict
410 Gone
411 Length Required
412 Pre Condition Failed
413 Request Entity too large
414 Request URI too long
415 Unsupported Media type
416 Request Range Not Satisfied
417 Expectation failed
418 I am a teapot
422 Unprocessable Entity
423 Locked
424 Failed Dependency
425 Unordered Collection
426 Upgrade Required
444 No Response
449 Retry With
450 Blocked by Windows Parental Control
499 Client Closed Request
5xx - Server Error
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway timeout
505 HTTP version not supported
506 Variant also negotiates
507 Insufficient Storage
509 Bandwidth Exceeded
510 Not Extended