Monday, 26 May 2014

Lazy loading tree with Force.com

I was trying to find something new to work, but nothing was making me eager to do that thing, and then I found out Jeff Douglas post of Original Post
Its an awesome post like he post every time, then I tried that thing in my personal salesforce org, and within few minutes I can see that tree in my org.

He's is using Jstree, its a jquery plugin, that provides interactive trees.
To know more about JsTree www.jstree.com

So that was so simple, and too much awesome, I would love to thank Jeff for doing such great things.
What he's exactly doing is to load an Objects tree, using Jquery, jsTree and Rest Javascript and using Lazy Loading.
There is a component that he created and called that component on the page.

Here how the tree looks

Here is the Steps need to perform

1. Create an Object named Parent Object.
2. Add a parallel look-up to the Parent Object of its own. Name the field "Parent Object".
3. Create a component named as "lazyLoadingTree". paste this code LazyLoadingTree
4. Create a Visualforce Page, name it ParentObject, paste this code ParentObject

5. Here is the Static Resource that you need to create, this is called from the Component that we created earlier, you cannot save your component without this restJavascript

Cheers..!!!
Happy Coding :)

Friday, 16 May 2014

reCaptcha Using HTML and Javascript ONLY...

Googles reCaptcha , its so easy to use it using PHP and .NET plugins, but I was trying to make it work only by HTML codes,

You can read this post of for reCaptcha without plugin CLICK ME
Unfortunately I tried to search, but everybody is using PHP, and upload that PHP file on server, to use it and make reCaptcha working, but I want a single code to make reCaptha working.

Here how it looks


As my code is not perfect, I have not done anything for the errors, but yes the reCaptcha's verification is working just perfect, it fetches response and shows it to you.
Here is the code(just paste it buddy)
reCaptch HTML

Hope I've helped..!!!

CHEERS :)



Tuesday, 6 May 2014

Opportunity "Probability" Field value assignment via "Stage" Field on VF Page

As you go to the Opportunity standard edit page, when you change the value of Stage field, the Probability fields value change accordingly like 10% or 30%. But the same functionality is not inherited by the VF page, so to perform this standard functionality we need to modify our VF page, as I have done.

This post is all about setting up the values of the Probability field of Opportunity associated to the Stage fields, as if you try this normally using VF page, this functionality doesn't work as standard salesforce functionality does, but doing some javascript stuffs, it can be done.

Here how it looks on VF page, by default these values are shown

Now change the Stage field value

Here the Probability field values changes with Stage value, as salesforce Standard functionality does.

Here is the small code for this,
VF Page Code


Happy Coding..!!!

Wednesday, 23 April 2014

Branding Of Your Salesforce Login Page

Login Page Branding:
Salesforce winter 14 release Bring a New Feature Login Page Branding, able to customize salesforce login page with their own Brand. Now you can change the look and feel of your login page by adding a background color, custom logo, and right-frame content.
Follow the Below Simple Steps to Do It.

Step 1 :

Your Name --> Setup --> Domain Mangement --> My Domain


Step 2 :
Provide your Domain Name


Step 3:

You will receive an email on your Email which you have provided in Salesforce Org, Click on that URL and get Logged in.


Step 4:

GO TO --> Your Name --> Setup --> Domain Mangement --> My Domain

Then click on Deploy To Users


Step 5:

Click on Edit button under Login Page Branding Section.


Step 6:

Upload a Logo and Click Save


Step 7:

Go to your Domain URL, that you got in email, and you can have some thing like this.


Isn't is looks good :)

Monday, 14 April 2014

Login Page With CSS Styling in Salesforce


Once I need to create a login page for salesforce sites, but it should look nice, so I used CSS to make my Login page look good, am sharing this, so that you don't waste time in just styling a Page.

Its as simply and perfect as it looks


Isn't it looks good,

Here is the CSS Style code, save this file in CSS format and make it a Zip file and save it in static resource.
"LoginStyles.css"

Here is the Apex Class (this is not perfect, You need to make changes to save)
"LoginController"

Here is Visualforce page.
"LoginPage"

Hope it will save some ones time.

Happy Coding..!!! CHEERS :)

Tuesday, 8 April 2014

Dynamic Look-up of all Objects, To Make Your Life Easy #Salesforce

Some days ago, I got an requirement of mass updating, everything was just fine but got stuck at Dynamic look-up, where I need to make a single look field but if user want to that he can change it to the another Objects look-up and save the record.

That means if I want to create a single look field having dependent on another picklist of Object Names,
If user selects Account Object, then our look-up field will pop-up the records of Account object.

But if user change the Object in the picklist and now he selects Contact object, then our look-up field will pop-up Contact records.

Here is the Snapshot for more understanding.

When you chose Account

And when you chose Contact from the picklist

Then your pop-up window will show me Contact records

The code is so simple but I just like the functionality so I thought to post it.
Hope some of you will like it.

Here is Controller Class "DynamicLookupController"

Visualforce Page "DynamicLookup"

Happy Coding..!!!! CHEERS


Thursday, 3 April 2014

Salesforce DEV 401 Certification Experience

I have just passed my Salesforce Developer Certification DEV 401, I was kind of afraid of it, because of the irony that I failed once already, so I don't want to repeat my past again.

My heart was gonna come out from my chest, when I was going to click on "SUBMIT" button, but let me tell you, its still in my chest.
Anybody, with determination can pass the examination, I found these questions usefull when I was preparing, hope this will help you all.
And I have some dumps, and study material to prepare, specially for DEV 401.

Only 3 things that I would like to refer all of you for the examination.

1. Sidhesh Kabe's Book of Salesforce.
2. Recruiter App. (Here)
3. Test yourself by propofs mock tests


Practice Test 1
Practice Test 2
Practice Test 3
Practice Test 4



And here is some question, that will help you, for more dumps you can email me.


Which of the following is related to View layer in MVC Model?


A. Workflow Rules
B. Validation Rules
C. Visual force Pages
D. Custom Objects
E. Apex Class



Which of the following represents controller in Model - View - Controller Model?


A. Tabs
B. Page Layouts
C. Custom Fields
D. Visual Force Pages
E. Apex Classes



Universal Recruiters wants to make access to records in such a way that all managers should be able to access records that are accessible to their team members. Which feature of Force.com's security should be used to implement this requirement. Select the one correct answer.

Object level access to profiles
Field level access to profiles
Organization wide defaults
Role hierarchy
Sharing rules
Manual sharing



Which of these is true about the Lookup Relationship. Select one correct answer.


Parent is not a required field and may be omitted.
Deleting an object deletes its children.
Roll-up summary field can be used to perform basic operations over all children of a parent record.
Security access of the child record is dependent upon the parent record.



Which of the following cannot be used to build a complete Custom Tab. Select one correct answer.


Display an external web page.
Display data using a VisualForce page.
Show data from a custom object using the native user interface.
Display the approval process using an Apex page.



Which of the following can not be translated via Translation Workbench?


A. Custom Report Type.
B. Standard Field Help.
C. Validation Error Message.
D. Report Name



Roll Up Summary fields work in which kind of relationship?



A. Many to Many Relationship.
B. One to One Relationship.
C. Master - Detail Relationship.
D. Lookup Relationship.



Based solely on the role hierarchy a manager can do all of the following EXCEPT:


A. View, edit, delete, and transfer his/her and his/her subordinate's records
B. Extend sharing on both his/her and his/her subordinate's records
C. View all folders his/her subordinate has access to, i.e., Reports, Documents, and Email Templates
D. View records his subordinate does not own but can view



Under what circumstances would the sharing button to be enabled on a detail view for a record.

A. A developer has added the button to the page layout
B. When record sharing is enabled in the user profile
C. When record sharing is set to public read only or private for the object
D. When record sharing is set to public read/write for the object



A developer has created a time-based workflow that escalates a Lead record 10 days after it has been created if no updates have occurred. What is the best way for the developer to test that the new time based workflow rule is functioning?


A. Create a new lead record; view the outbound messages queue
B. Setup the developer for time-based workflow queue; create a new lead record; view the time-based workflow queue
C. Create a new lead record; view the time-based workflow queue
D. None of the Above



All the very best for your Exam...!!!

Thursday, 13 March 2014

Salesforce Cron Format

For those unfamiliar with "cron", this means being able to create a firing schedule such as: "At 8:00am every Monday through Friday" or "At 1:30am every last Friday of the month".

A "Cron-Expression" is a string comprised of 6 or 7 fields separated by white space. The 6 mandatory and 1 optional fields are as follows:


Field Name              Allowed Values           Allowed Special Characters

Seconds                         0-59                    , - * /

Minutes                         0-59                    , - * /

Hours                           0-23                    , - * /

Day-of-month                    1-31                    , - * ? / L W C

Month                       1-12 or JAN-DEC             , - * /

Day-of-Week                 1-7 or SUN-SAT              , - * ? / L C #

Year                    (Optional) empty, 1970-2099     , - * /

The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".



The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.

The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".

The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".

The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.

The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.

The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.

The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".

The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.

The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".

The legal characters and the names of months and days of the week are not case sensitive.


Pay attention to the effects of '?' and '*' in the day-of-week and day-of-month fields!

NOTES:

--> Support for the features described for the 'C' character is not complete.
--> Support for specifying both a day-of-week and a day-of-month value is not complete (you'll need to use the '?' character in on of these fields).
--> Be careful when setting fire times between midnight and 1:00 AM - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.

A normal scheduling expression to for a Scheduler Class that will run on every Friday of the Week at 4 PM.

Sched_WeeklyStatus m = new Sched_WeeklyStatus();
String sch = '0 0 16 ? * FRI';
String jobID = system.schedule('Send Reminder for Work Status', sch, m);


To schedule every 15 minutes, use below one

System.schedule('Scheduled Job 1', '0 0 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 2', '0 15 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 3', '0 30 * * * ?', new ScheduledClass());
System.schedule('Scheduled Job 4', '0 45 * * * ?', new ScheduledClass());

Happy Coding..!!!!

Thursday, 13 February 2014

Calender Home Page Component Using Visualforce Page

This is one of the simple, easy but good looking post. In this one I have done nothing extra effort. It is just a component on your home page layout where you can Write your note, Create event and task just by one click. No need to go to home page for the calender and all the stuffs related to it.

Here how it looks, not too bad I think..!!


To add this on your home page layout, first thing need to do is to create a Visualforce page
Click here Calender Component

After saving your Visualforce page

Go to ==> Setup --> Home --> Home Page Components --> New

Write the Name --> Select HTML Area --> Next

Then paste this code just as shown
<iframe src="/apex/Calender" width="100%" height="100%"></iframe>


Then click Save
Now go to SetUp --> Home --> Home Page Layouts --> Edit


Click Next --> Set the Position of your component and click Save.
Hope helped someone.

Friday, 7 February 2014

Show IP Address on Visualforce Page Salesforce

This is one of the thing, that previously I never thought that it would be help full, but at some point it is.

When you want some where to show the current user's Ip address on page, OR weather you want to restrict a User of a particular IP then you can use this small code snippet with some booming functionality.

Apex Class ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

public class IPAddress {

    //Variable to hold the IP Address value for current logged in user
    public String ipAddress {get; set;}

    //Constructor
    public IPAddress() {

        //Map to hold current URL header parameters
        Map<String, String> mapHeaders = ApexPages.currentPage().getHeaders();  

    //Proceed further only and only if map of header parameter have not null value with it
        if(mapHeaders != null) {

            ipAddress = mapHeaders.get('True-Client-IP');
            if(ipAddress == null){
                ipAddress = mapHeaders.get('X-Salesforce-SIP');
            }
        }
    }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

VisualForce page ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

<apex:page controller="IPAddress">

<h1> Current Logged In User IP Address ::::: </h1>   {!IpAddress}

</apex:page>

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

and here it is..!!!!


HAPPY CODING...!!!

Friday, 3 January 2014

Javascript Data Table in Salesforce

Salesforce provides its own datatables attributes to show your data on visualforce pages, but its kind of slow and requires heavy coding to add Sorting and Paging things on it.
So if we try for javascript for this purpose, its so easy and fast on the UI.

Here I have created a Generic Component where, developer just need to pass the name of the list(having records of an Object), with Name of the headers of the list. and that component will do everything to show a multifunctional table on the page.

And then table will look something like below, having records of Account object.


You can check the functionality of the above table on this link Javascript Datatable

Here is the Visualforce page using a Component.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
<apex:page Controller="JQDatable">

  <!-- Calling component having list and Header of the table -->
  <c:DataTableComponent listOfRecords="{!accounts}" fieldHeader="Name,Phone,AccountNumber,Type,Owner.Name" />
</apex:page>

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Developer just need to pass the name of the List with correspinding name of the fields here is the Controller class of the above pages

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
public with sharing class JQDatable {

  //List of Account
  public List<Account> getAccounts() {
     return [SELECT Id, Name, Phone, AccountNumber, Type, Owner.Name FROM Account];
   }
}

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

All this simple code showing such functionality becuase of the component, refer these below links to have the Component as well as Jquery and CSS files that have been used.

Here is Component and its Controller
Datable Component Controller
Datatable Component

Jquery and Css files used in Static resource()
jquery.js
jquery.dataTables.js
Demo_table.css

After saving all above, you can have a Generic Component to show a multi-functional Data table in salesforce.

Happy Coding...CHEERSSS..!!!!