How to create S-Control in Salesforce

To demonstrate this, lets consider an example of Google Map.

Lets create a S-Control for the Google Map.

Now let’s first create a new S-Control:

  1. Click on “Setup” which is located on the top right corner of the page.
  2. Expand “Develop” item and click on “S-Controls”
  3. Hit “New Custom S-Control”
  4. Provide a Label “Google Map” and a description is you wished to
  5. The Type should be HTML since we want to create a HTML, Google API mash up
  6. Now it is time to enter the code for the S-Control
S-Control in
<html xmlns="" xmlns:v="urn:schemas-microsoft-com:vml">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Maps JavaScript API Example: Advanced Directions</title>
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv"
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv"

<script src=";v=2.x&amp;key={YOUR KEY}"

<script src="/js/functions.js" type="text/javascript"></script>

<script type="text/javascript" src="/soap/ajax/13.0/connection.js"></script>

<style type="text/css">
body {
font-family: Verdana, Arial, sans serif;
font-size: 11px;
margin: 2px;
table.directions th {

img {
color: #000000;

<script type="text/javascript">

var map;
var gdir;
var geocoder = null;
var addressMarker;
var dirFrom = '{!$Request.from}';
var dirTo = '{!$}';
var mapLocale = ""
var SControlID = '{!$Request.lid}';
var SFrameIC = '{!$Request.ic}';

function initValues()
mapLocale = "en_US";


function setInputFields(from, to)
window.document.getElementById("fromAddress").value = from;
window.document.getElementById("toAddress").value = to;

function initialize()

if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);

setDirections(dirFrom, dirTo, mapLocale);

function setDirections(fromAddress, toAddress, locale) {
if ((fromAddress) && (toAddress))
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });

function handleErrors()
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.n Error code: " + gdir.getStatus().code);

else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.n Error code: " + gdir.getStatus().code);

// else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.n Error code: " + gdir.getStatus().code);

else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. n Error code: " + gdir.getStatus().code);

else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.n Error code: " + gdir.getStatus().code);

else alert("An unknown error occurred.");


function onGDirectionsLoad(){
// Use this function to access information about the latest load()
// results.

// e.g.
// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
// and yada yada yada...

<body onload="initialize()" onunload="GUnload()">
<div style="background-color: #CCCCCC">
<form action="#" onsubmit="setDirections(this.from.value,, this.locale.value); return false">
<th align="right">
<input type="text" size="25" id="fromAddress" name="from" value="" /></td>
<th align="right">
<td align="right">
<input type="text" size="25" id="toAddress" name="to" value="" /></td>
<th align="right">
<th align="right">
<select id="locale" name="locale">
<option value="en" selected="selected">English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="ja">Japanese</option>
<option value="es">Spanish</option>
<input name="submit" type="submit" value="Get Directions!" /></td>
<div style="border-width: 1px; border-color: #000000; border-style: solid;">
<div style="overflow: auto; width: 99.5%; height: 380px">
<table class="directions" style="width: 100%; height: 100%">
<td valign="top" style="width: 275px;">
<div id="directions" style="width: 275px; background-color: #ffffff;">
<td valign="top">
<div id="map_canvas" style="width: 100%; height: 375px; background-color: #ffffff;">

Difference between Sandbox and developer edition in Salesforce

A test environment for is crucial to change control. provides the tools needed to test anything in a test environment before you implement it in your live instance. You can either test in a Sandbox environment or in a Developer environment. What is the difference? I will share what I know…


The Sandbox environment is an exact copy of your instance. You can copy your live instance to a sandbox environment (but you have to perform manually from sandbox to developer edition) where you can test any changes, implementations, AppExchange apps or updates. It can also be your hands-on training environment without risking your live data.

You can either copy your configuration and data into a sandbox environment or just the configuration. It acts exactly like your live instance, but be careful if you have workflow rules or automations because they will work in the sandbox as well.

I know that this sounds wonderful and if you don’t have it, you are dying to know how to get it. The problem is the cost. If you are on Unlimited Edition, then cost is not a problem because it comes included. But for Enterprise, Professional or Group Editions, you have to pay… and the price is hefty; anywhere between 25k-50k per year. For a lot of companies, that is more than they are paying for their live instance. So how do you test without Sandbox?  It is always suggested to develop application in sandbox instance then go for LIVE.

Developer Edition

Developer Edition was an edition created for development of integrations and apps, specifically for the AppExchange. It is also a great tool for testing/training in What makes this a great tool is the fact that it is free. Anyone can get a Developer Edition of It is a standard Enterprise Edition with very limited storage space. You cannot copy your configuration or data onto the Developer Edition, but you can customize it to match your instance’s look and feel. Once it is customized, you can use it for training, testing or anything else you want. It takes a little bit of work, but you can make it act and feel just like your live instance. The work is well worth it for the free price.

To get a copy of Developer Edition for yourself or your company go here. Play around with it. Get apps from the AppExchange. Do anything and everything that you have been scared to do your live system. If you come up with a clever way of using the system, post it on AppExchange and share your knowledge.

Create Cron job to run PHP Script in Cpanel

Hi All,

Today i just want to share that how to create  a cron job in Cpanel to run the PHP script.

I hope everyone knows that what is Cron job : it is the task schedule in Linux which will run on predefined time interval. its same concept like schedule tasks in Windows OS.

To create the cron job, open the Cpanel and select “cron jobs”.

Select Cron job in Cpanel

You can see that in drop down list there are lots of common schedules of crone job, you can select it, or create your own schedules.

Common settings in Cpanel

In Command text box, write the PHP program path and file to be executed like:

/usr/local/bin/php -q /home/<username>/script.php

to find the path to php,
log on to the server with SSH, then run this command:
which php
whereis php
This will give you the path to the php executable, probably:

Applying the Support Packs in SAP System

SUPPORT PACKS:-  Support Packs provides enhanced functionality, Bug fixes, changes to the existing Data Dictionary Elements, Repository objects like programs, reports, transactions etc.  Support Packs are of various types. Few of them are:

 Basis Support Packages (SAP KB 62050)

ABAP Support Packages (SAP KA 62050)

Application Support Packages (SAP KH 47050)

HR Support Packages (SAP KE 47050)


1. SPAU and SPDD list should be checked before start of support package application.

2. Objects in repair state needs to be released. 

3. It is recommended that latest SPAM/ SAINT version should be applied before starting and Support Package application.

4. Enough space to hold the support packs in “EPS” in directory USR/SAP/TRANS/EPS/IN. There should be no aborted packages from previous support pack or Plug In applied.

5.  Support Packages should be applied in the sequence of number of support packs.

6. Technical & functional consultants need to be informed while applying support packages.

7. Schedule downtime and inform the users.

8. Go through composite note thoroughly before applying support packs. If the support pack is  greater than 10MB then uncar the file using command SAPCAR – XVF .sar. When we uncar, two files are generated with extensions .ATT&  .PAT


1. Go to transaction code Spam

2. Load Packages from the presentation server/Application server

3. Display all the new support patches to be applied

4. Select the support package to be applied

5. Import the Queue Support Package starts upgrading the system and it goes into various phases like TP connect to DB, DDIC import, DDIC Activation. These phases can be found in Table PAT01.  While applying support packages its stops to run SPAU/SPDD.

 SPAU: This is the transaction to update repository objects like programs, reports, transactions, function modules while applying support packs. This is the phase where functional consultant’s assistance is required.

SPDD: This is the transaction which is used to update Data Dictionary Elements while applying support packages. This is the phases where functional consultant’s assistance is required.

Note:  If the objects are changed earlier with the help of SAP notes, now these notes are part of the support packs which are modifying the system. In this scenario each and every object which were modified earlier with the help of Note are popped up on the screen whether to keep the original or change to newer version.

Categorized as SAP Tagged

Dos command to close and open port

1)Type  netstat -a -o -n in command prompt.

Netstat command in DOS
Netstat command in DOS

2) find the PID number for that port number (as shown in above image).
3) goto task manager and end process the corresponding PID number.

Close Open Port from Task manager in Windows xp
Close Open Port from Task manager in Windows xp

If  PID is not visible in task manager then goto View->Select Column and select PID column.

How to Install java on Ubuntu 10 and Ubuntu 11

Run below command on the terminal of ubuntu to install the JAVA.
Ubuntu 10 :
	$ sudo add-apt-repository "deb partner"
	$ sudo apt-get update
	$ sudo apt-get install sun-java6-jdk
	$ sudo apt-get install sun-java6-jre

Ubuntu 11:

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-jre
sudo update-alternatives --config java

Get Mouse Position in JavaScript for all browsers


Get Mouse Movement in Javascript
Get Mouse Movement in Javascript
function mouseXPos(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ?
document.documentElement.scrollLeft :
else return null;

function mouseYPos(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
return evt.clientY + (document.documentElement.scrollTop ?
document.documentElement.scrollTop :
else return null;

To use above function, just pass the mouse event.

Live Demo

Why Style.left does not work in Firefox, chrome and safari ?

During working on one of my project, i found that style.left does not work with Mozilla, chrome and safari but nicely works on internet explorer.

The code was :

var docStyle = document.getElementById("divAddPartnerAndProjectEntities").style; = e.clientY;
docStyle.left = e.clientX-5;
docStyle .style.display = "";
And the simple solution is, append “px” at the end to work with other browsers.
and final code is:
var docStyle = document.getElementById("divAddPartnerAndProjectEntities").style; = e.clientY+"px";
docStyle.left = e.clientX-5+"px";
docStyle .style.display = "";

Very Simple right ? 🙂

DataGrid Sorting and Paging Example – Part 2

For Part 1, visit This URL

In this part, i will show that how to Sort the Datagrid Component of ASP.NET.

To sort Datagrid, we will need DataView and then assign Dataview as datasource to our Grid control.

We will need to change our code of Part 1.

Previously, we used DataSet as a Datasource. This time we will use DataTable and get the DataView from DataTable using below line.

DataView dv = dt.DefaultView; //Where dt id DataTable

So we have created a function, which will return the DataTable as shown below:

private DataTable GetTableFromDataBase()
SqlConnection con = null;
SqlDataAdapter adp = null;
DataTable dt = new DataTable();
con = new SqlConnection(conString);
adp = new SqlDataAdapter("Select * from Employee",con);
return dt;
catch (CustomException ex)
return null;

we will need to create the function on Sortcommand of the DataGrid.

The format for sorting the grid is like:




Below is the code snap used for the sorting:

protected void grdEmp_Sort(object source, DataGridSortCommandEventArgs e)
DataTable dt = GetTableFromDataBase();
DataView dv = dt.DefaultView;
string dir = string.Empty;
if (e.SortExpression.Length > 0)
if (Session["OldSortDir"] == null)
Session["OldSortDir"] = e.SortExpression;
string oldSortExp = Session["OldSortDir"].ToString();
if (oldSortExp == "asc")
dir = "desc";
Session["OldSortDir"] = "desc";
dir = "asc";
Session["OldSortDir"] = "asc";
dv.Sort = e.SortExpression+"  "+dir;
grdEmp.DataSource = dv;

The code for the Pagination is written below. Consider Page Size as 3.

protected void grdEmp_Paging(object source,DataGridPageChangedEventArgs p)
grdEmp.CurrentPageIndex = p.NewPageIndex;

Download Source code

DataGrid Example – Part 1

For the basics of DataGrid please refer this post:

In this example, i will explain the basics of DataGrid control like Theming, Databinding etc.

We will start our example with creating the SQL Express database of Employee which will contain the following fields : Id, FName, LName, Email.

Now create a stored procedure to insert the data into Table.

@FName varchar(50),
@LName varchar(50),
@Email varchar(50)
INSERT INTO Employee (FName,LName,Email) values (@FName,@LName,@Email)

In ASPX page, write the code to input the Employee information.

First Name : <asp:TextBox ID="txtFName" runat="server"/><br />
Last Name :<asp:TextBox ID="txtLName" runat="server"/><br />
Email :<asp:TextBox ID="txtEmail"; runat="server"/><br />
<asp:Button ID="btnSubmit" Text="Add Record" runat="server" OnClick="btnSubmit_Click"/>

Go to the property of Employee.mdf and select connection string as shown in below image.

On the click event of the button write below function:

string conString = @"Data Source=.SQLEXPRESS;AttachDbFilename=""|DataDirectory|Employee.mdf"";Integrated Security=True;User Instance=True";
protected void btnSubmit_Click(object sender, EventArgs e)
SqlConnection con = null;
SqlCommand cmd = null;
try {
con = new SqlConnection(conString);
     cmd = new SqlCommand("AddEmployee", con);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@FName", txtFName.Text);
     cmd.Parameters.AddWithValue("@LName", txtLName.Text);
     cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
catch (CustomException ex) {
 private void showConfirmationMessage()
      ClientScriptManager csMngr = Page.ClientScript;
      csMngr.RegisterStartupScript(Page.GetType(), "Success", "alert('Record Added succesfully');", true);

ASPX Code for data grid

<asp:DataGrid ID="grdEmp" runat="server">
<HeaderStyle CssClass="Header" />
<AlternatingItemStyle CssClass="AlternateItemStyle" />

Write below code to bind the data into DataGrid.

private void bindData()
SqlConnection con = null;
SqlDataAdapter adp = null;
con = new SqlConnection(conString);
adp = new SqlDataAdapter("Select * from Employee",con);
DataSet ds = new DataSet();
grdEmp.DataSource = ds;
catch (CustomException ex)

Final output:

Download Code