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...!!!