Showing posts with label apex. Show all posts
Showing posts with label apex. 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, 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

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


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.

Monday, 10 March 2014

yes/no confirm pop up dialog box using jquery.





Hi Guys,

I am writing this post because some one comment on my blog and asked me for this requirement, i am happy to help him,

http://anuragsfdc.blogspot.in/p/salesforce-limits.html

his requirement is to show Yes /No buttons in place of Ok/Cancel buttons of javascript confirm function.

so for this i am creating a custom pop up dialog using JQuery.

here the code for same:-

here the screen shot:-


hope it helps, happy coding...

Thanks

Friday, 7 March 2014

SOQL Query on vf page using javascript without any controller.






Hi friends,

Many times you need record value on vf page for validation / viewing or for any other reason,
then you have to write a custom controller for query record.

here the example which show how you can query from vf page without any controller,
simply use JavaScript for query.


you can change the query according to your requirements.

Hope it helps
happy coding...:)
thanks
Anurag Jain

Tuesday, 11 February 2014

Send email with attachment from Apex class and VF Page in salesforce.





Hi friends,

This post shows how to send Email with Attachment using Apex Controller and VF Page.

I am writing this post because it’s a common requirement to sends emails from salesforce with attachment to clients, contacts etc.

As per my knowledge there are two ways to send email from Apex:-
1.      By using email templates.
2.      By using Messaging class.

Here I am using Messaging class for sending email from apex class:-



Screen shots:-





hope it helps, happy coding...

Monday, 6 January 2014

Genrate Bar Codes from UPC or SKU by REST API.







Hi friends,

By this post I’ll show how to save Bar Code in Salesforce by using UPC code,

I call web service of third party which gives the image of Barcode (by using REST Api’s) and that image is Saved in the Notes and Attachment of Product.

Here the Sample code for same:-

Screen Shots:-