Thursday, June 30, 2016

How to load Jquery or other scrips by console or lazy loading in page

Hi So the other day I was updating a few checkbox manually and then thought then why not do it by Jquery, as soon as I ran the famous selector and prop function chrome throw me error of undefined.
It was due to no jquery loaded in the context or DOM.
To do this there is a simple trick just open the console and paste the below script.


This can also be loaded in page after some execution or even inside "$( document ).ready() {}".

Friday, June 10, 2016

How to "break" pass by reference in Lightning attributes

Hi,
I resently came by the problem in Lightning Aura development. I was developing a page to show some components on the page, the requirment was that user can deselect some of the rows and then data has to be rearranged accordingly simple right!.

I also thought so the approch I took was to have two list one for the values to display and another to hold the cloned values, so if the user rests all I can replace it with clone values and done. What happen in auro if the two variable are seprate but you filled them using a single source of reference then they are pointing to the same memory and hence if one changes other implecitly chnages. To eleminate this proble I simply used "JSON.stringify".

What this will do is when you have your values from controller to JS component then convert it into a well formated structure and then using "eval" convert it back to object. This will break the pass by  reference problem and two values can be independent.

Sunday, March 27, 2016

How to automate your salesforce deployment using Ant

Recently I was thinking to make automatic deployment mechanism to save time that was invested in weekly deployments. So after scratching the surface of Ant Migration Tool I cam up with this script to automatically extract and deployment class and trigger from one org to another.

Option 1-
Step 1. Must have JDK 1.6 or higher
Step 2. Install Ant to your machine use this "http://ant.apache.org".
Step 3. Download Salesforce Ant Migration ZTool Jar package.
Step 4. Create/Clone two folder using the sample folder in the zip.
Step 5. Provide Username password to both the Build.property files.
Step 6. Use this code and save it to Auto.bat in any location
ECHO Retrieve and Deployment auto script started..
cd\
cd <Path to>\Retrieve Meta
start /W ant retrieveUnpackaged ^&^& exit
Xcopy  /S /I /E /Y "<Path to>\Retrieve Meta\retrieveUnpackaged"  "<Path to>\Deploy Meta\codepkg"
ECHO Retrieve file copied to Deployment folder..
cd\
cd <Path to>\Deploy Meta
start /W ant deployCode ^&^& exit
ECHO Retrieve and Deployment auto script stoped..
PAUSE Press Enter to close

Where <Path to> is the path where you extracted the Ant Migration Tool and cloned folders.

Option 2-
Have a ant build.xml configured with two targets first for retrieve and second for deployment and link them inside another target like <target name="all" depends="retrieve, deploy">
</target> then open cmd and run this
ant -f build.xml all

Monday, September 14, 2015

Convert your Metadata object structure to "XLS"

Ok so today one of my requirement was to convert the whole Metadata object structure to XLS information for a client and so I maked a small java program to do it.

Note: the file have to be downloaded by using force.com IDE and just place it in the new location and run this code:
What it will do is to convert the .object files into a single XLS file to be read as a object definition, its use full if you need to constantly use XLS for reporting and audit.
Download link: HERE

Thursday, October 16, 2014

How to use Streaming API in visualforce Salesforce

Ok so as per new enhacnement Slaesforce has introduced streaming API in force.com. The cool thing is that it works on "Comet" model, its accually a long-held HTTP request model. So if a connection is open it will get the new updates through polling. The server will pust the new data into the stream and thus we will get notification in page without even using page reload or API request.


Result:

Hope this helps you!!