Wednesday, November 2, 2016

How to get site user in debug logs Winter17

So after winter17 we cannot see site user debug as a salesforce update.

To enable that we have to set cookies in user browser.

In chrome open inspect element>console and paste this.
Document.cookie="debug_logs;domain=.force.com";

Thursday, July 28, 2016

Apex inputField issue with dataTable,pageBlockTable and repeat

When working with <apex:inputField> inside dataTable,pageBlockTable with wrapper objects you have to use <apex:column> if you donot use it visualforce pahe will result inot an error saying

"<apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."

To over come this you have to use <apex:inputField> inside <apex:column> or you can use <apex:repeat> instead, when you use <apex:repeat> you have to design the table structure yourself.

Monday, July 18, 2016

Using Salesforce SOAP API in Ajax

Just a small post(its a very old functionality but I just posted it now) for how to create record using /soap/ajax/ in Salesforce. The code can be written in Visualforce page as well as Custom button as javascript.

Reference: SOAP API

Usage:
  1. Can be used to create record like logs or attachments from javascript hence reducing server processing time.
  2. Can query record to check values in page layout buttons.

Friday, July 1, 2016

How to have a image crop functionality in salesforce

Many time there is a custom requirement(generally in community) that a user can upload images, and when they do so there should be a functionality to crop or rotate it. We can achive it by using "corpper.js" Link.

Note: This page will through a viewstate error, due to base64 string size, try using transient variable to solve this.


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