Showing posts with label anuragsfdc. Show all posts
Showing posts with label anuragsfdc. Show all posts

Tuesday, 9 February 2016

Show all contacts from Child Accounts in parents account.






Hi All,

I am writing this post because 2-3 clients came up with this same requirement, to show all the contacts of child Accounts in their parent Account.

I am explaining this requirement in detail with an example:-
Suppose there is Account "A" who is parent of Account "B".
now account "B" has 2 contacts "B1" and "B2".
client want to see this "B1" & "B2" contacts in parent account "A", so that he can easily know which contact associated with which account on same page easily.
And this is not only limited to 2 level it is goes to up to 100 level (we can't Query more then 100 in one context because of Governor limit).

I solved this problem by creating a VF page and add it to Detail page of Account, So now user can able to see all the contacts associated with the Account and their child Accounts in a same page.

Here the code:-

Screen Shots:-


 Happy Coding...:)
Thanks
Anurag Jain

Thursday, 21 May 2015

Image Croping Tool with JS and JQuery in VF page.

Hi Guys,


In this post i am going to show how we can crop an image and upload it in Documents Object of Salesforce.

I am taking a simple example and following the below mentioned steps:-
  • Create a VF page which has a upload image link.
  • on click of upload link i am opening a pop up of another VF page which is used to select image file from local system.
  • now after selecting file click on upload button.
  • after clicking on upload button magic is started now you can zoom-in, zoom-out or drag image and can easily select part of image you needed to upload in salesforce document.
  • Finally on click of save button image is inserted in document object and pop up window is closed.
Here the code:-

Screen Shoots:-
Upload Picture Page

On click of upload link opened popup page

choose picture from local system

selected picture get uploaded

Zoom Out picture

Zoom In Picture

Finally crop Picture

cropped picture saved


Hope this helps...happy Coding

Thanks
Anurag Jain

Thursday, 19 February 2015

Send Email using Apex and vf page by using email templates.





Hi friends,


Previously in this post I showed you how we can send emails using Messaging class, but many times we need to send email using email templates in apex code.

So in this post I am using email templates to an send email from apex code:

I am using 2 vf pages and 2 controller in this example:-

  • SendEmailByTemplateVFPage - This is the page from where we are sending Email from template.
  • ClsSendEmailByTemplate - This is controller class of "SendEmailByTemplateVFPage".
  •  SelectTemplate - This is another vf page which is calling from "SendEmailByTemplateVFPage", in this page we are querying all the Email Templates.
  • ClsSelectTemplate - This is controller class of "SelectTemplate".

Here the code:-

Screen Shots:-






Happy Coding...:)

Thanks
Anurag Jain

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