Sunday, 16 November 2014

Expand and collapse link for an Div in vf page using Jquery.

Hi Friends,

This is a small but useful post to maintain UI of your Visualforce page,

to add show more link(for expand) and show less link(for collapse) on div (or any other HTML tag) when div height is more then expected size.

Look at the screen shot below:-


So to solve this issue you can use the following java script and jquery:-


Screen Shots:-



Hope this helps..

Thanks
Anurag Jain

Thursday, 25 September 2014

PageBlockSections with different colors at each section.





Hi friends,

Few days ago, one of my client come up with this requirement,

He wants to see all sections on the detail page in different color so that he can easily differentiate (or group) fields of the custom object according to color code like red section fields blue section fields,

Generally each section on the detail page has the same color as their tab,


so for this requirement i have created a vf page and put that page in the detail page layout,

I am using FieldSet here so that we can easily add and remove fields from vf page later without touching code of vf page.

Note:-
Before using this code must create FieldSet, for creating FieldSet go to your custom object and select new FieldSet.(for more detail see this link).

Here i am using three FieldSets name as
  1. FieldSet1
  2. FieldSet2
  3. FieldSet3
Here the code of that vf page:-



Screen Shots:-


Happy coding..:)
Thanks,
Anurag Jain

Tuesday, 8 July 2014

Required field using custom controller on VF page.





Hi friends,

Recently i was working on a complex visual-force page, where page has lot of render and reRender.
My requirement is to make some fields mandatory on vf page but page as some javascript and reRender on save button which creates problem while i am making field mandatory using required attribute of <apex:inputfield> tag.

So to solve this problem i have maked field required by using custom controller and field having same look and feel as standard required attribute because i am using same standard CSS which standard inputfield is used on required field attribute.

Here the VF page and controller:-

Screen Shoots:-


Cheers!!!
Anurag Jain

Friday, 13 June 2014

Read XML easily in salesforce.

  
 
Hi Guys,
Few days back i was working on an integration of Salesforce with Zoho,
in that integration i am calling web services of Zoho from Salesforce by using REST API's,
i am getting response in form of XML from ZOHO and it takes my couples of hours only for
parsing(reading) that XML.


So in this post i am showing you how can we read an XML easily and take-out our
required data from XML, it will save your lot of time and effort... :)

here i am uploading an XML from VF page using <apex:inputfile>tag
and showing the result on same VF page in <apex:pageblocktable>.

 
Here the Code:-


Screen Shots:- 



Happy Coding...:)
Thanks
Anurag Jain


Saturday, 31 May 2014

Adding summary field as footer of pageblock table in vf page.





Hi All,

This post is simply showing how can we add the summary field or total amount or other information in footer of PageBlockTable or DataTable in vf page.

Here, in the following example I am showing sum of all the opportunity line items in footer of PageBlockTable,

i am using the <apex:facet name="footer"> tag to show the value in the footer.

Here the code:


Screen shot:

Thanks
Anurag Jain



Wednesday, 7 May 2014

Insert Records in SF by using JavaScript without Apex classes or controller.





Hi guys,

In this post i am showing how can we use the power of javascript in VF page and inserting record in salesforce without any standard/custom controller or Apex.

By using AJAX Toolkit we can do this task easily.

AJAX Toolkit divides in two type synchronous and asynchronous call.

It works in three simple steps:
  1. Connecting to the AJAX Toolkit(By using login methods or getting Session_ID)
  2. Embedding the API methods in JavaScript.
  3. Processing the results.
in following example i am using synchronous call :-


Screen Shoots:-


 After inserting of record you are having ID of record :-


Happy Coding...:)

Thanks
Anurag Jain

Wednesday, 23 April 2014

hierarchy chart on vf page by using google chart.






Hi Guys,
I am writing this post to show how we can create a beautiful chart showing hierarchy level for Account on detail page, 
all Contacts shows according to their reporting managers for an Account.

here I am using Google chart in VF page and apex class,
for this requirement i am creating a string "ContactData" and using it on VF page that's it.

following is code for extension class and vf page:-

Screen shoot:-



Note:- chart is shows only if you fill the "Reports To" field at contact level.
Happy coding...
Thanks
Anurag Jain.