Wednesday, January 30, 2013

Entitlements Overview:

Entitlements Overview:
If your call center agents are receiving more calls with complex questions than ever before.
Agents rarely have time to verify service levels, and are instead responding to customers whether or not they have a valid service level agreement .As call volume increases, customers satisfaction at risk.
Agents need a better way to identify entitled customers so they can effectively respond to their needs.
Identifying the stakeholders and identifying requirements for entitlement management is critical to project success. Salesforce entitlement managements allows companies
                Defines service level for support
                Manage entitlements and service contracts
                Verify if customers are eligible for support
                Enforce service levels via automated processes
                                                           
If agents are supposed to identify an entitlement, account, contact and asset when resolving a customers issue to ensure agents meet service level agreements.Cases should automatically display the correct entitlement, account, contact, asset.To help agents drive new revenue with entitlements in salesforce, they need the service contracts and contracts line items object.Service Contracts allow agents to track contracts for customer support.If the products enabled it looks like this

you need to choose right model before you enabled and setup entitlements.With no service contract, use the entitlements only model. With a service contract, use entitlements with service contract model;and for service contract and line item management, use the entitlements with service contracts and line items model. Enabling entitlements explained in my previous post .





             

Monday, January 21, 2013

Default Text :

Default Text :
This example shows how to generate a default text in your required fields. You can try sample example using  your custom object api.  Here once you created visualforce page override your new button on your custom object with this vfp.

public class AcctPlatformExtension {
  public AcctPlatformExtension(ApexPages.StandardController controller) {
    Forecast__c t = (Forecast__c)controller.getRecord();
    t.Name= 'AutoGeneratedName';
  }
  public static testMethod void test() {
   Forecast__c t = new Forecast__c();
    ApexPages.StandardController controller = new ApexPages.StandardController(t);
    AcctPlatformExtension extension = new AcctPlatformExtension(controller);
    System.assertEquals(t.Name,'AutoGeneratedName');
  }
}

<apex:page standardController="Forecast__c" extensions="AcctPlatformExtension">
<apex:sectionHeader title="Forecast__c Edit" subtitle="{!Forecast__c.name}"/>
 <apex:form > <apex:pageBlock title="Forecast__c Edit" mode="edit">
 <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}"/>
 <apex:commandButton value="Save & New" action="{!save}" />
  <apex:commandButton value="Cancel" action="{!cancel}"/>
   </apex:pageBlockButtons> <apex:pageBlockButtons location="bottom">
   <apex:commandButton value="Save" action="{!save}"/>
    <apex:commandButton value="Save & New" action="{!save}" />
    <apex:commandButton value="Cancel" action="{!cancel}"/>
    </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2">
     <apex:inputField value="{!Forecast__c.Name}" required="true" />
     <apex:inputField value="{!Forecast__c.OwnerId}" required="false"/>
     <apex:inputField value="{!Forecast__c.Status__c}" required="false"/>
     <apex:inputField value="{!Forecast__c.Civil_Military__c}" required="false"/>
      <apex:inputField value="{!Forecast__c.Airframer__c}" required="true"/>
      <apex:inputField value="{!Forecast__c.Account_Sub_Type__c}" required="false"/>
      <apex:inputField value="{!Forecast__c.Forecast_Platform__c}" required="true"/>
      <apex:inputField value="{!Forecast__c.Sales_Org__c}" required="false"/>
      <apex:inputField value="{!Forecast__c.Child_Account__c}" required="false"/>
       <apex:inputField value="{!Forecast__c.Region__c}" required="false"/>
       </apex:pageBlockSection> </apex:pageBlock>
       </apex:form>
       </apex:page>



Monday, January 14, 2013

Migrating Translation Fields/Components:

Migrating Translation Fields/Components:
if your machine does not support a language to be edited in its proper format and re formats the content into some garbage characters. This might be the case with chinese, japanese and for all the languages that do not use 'script' similar to english.

The steps are quite easy with just one DON'T..what? wait for a minute, you'll get to know soon..
I am assuming that you know how to use Force.com IDE. Now

  • Create a Force.com package using your credentials for your source environment/sandbox
  • While selecting metadata components, select second option (i.e. Choose manually)
  • Expand "objects" and select the object(s) whose translation you want to migrate (including field translations). Example: Account, MyObject__c
  • Expand "translations" and select the languages for which the translation is done. Example: ja, zh_CN
  • Next expand "objectTranslation" and select the translation for the objects in step3 and select the labguage for those objects in step 4.
Now when you will click Next and Finish, three folders should be there in your project's "src" folder, viz. object, tranaslation and objectTranslation. And here is that DON'T. DO NOT open any objectTranslation file on your machine. just keep them as they are. Although you can open a fine that supports your "keyboard". for example if you are using an english keybord, you can open French or German file and so on.
  • To deploy this to your target environment/sandbox, right click on project --> Force.com -->Deploy to server
  • Enter the credentials
  • On the next page, "Deselect All" the components, then manually select only the objectTranslation file (assuming you have already migrated objects and have set up the language otherwise select all the components)
  • Validate your deployment before clicking Next
  • Click Next when you get a Green signal
  • And yayy..you are done..
See how simple. For further reference go to
http://wiki.developerforce.com/index.php/Documentation#Usage_and_Implementation_Guides

and the book is Localizing with the Force.com IDE.
Here is the direct link

Visualforce Creator:

Visualforce Creator:
This is definitely useful when you want to use standard functionality in your custom visualforce page.

public class OutputController {      
    //variables and getter/setter
    public String output {get;set;}
    public String hide {get;set;}  
   
    //action method of the button
    public PageReference create() {
        output = hide;
        return null;
    }        
   
    //test method
    public static testMethod void testPage(){
        Test.setCurrentPage(Page.VisualforceCodeCreator);
        Test.startTest();
        OutputController oc = new OutputController();
        oc.create();
        Test.stopTest();
    }
}

<apex:page controller="OutputController">
<apex:form >

<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>

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

<script type="text/javascript">
//var output='';
function setupPage() {
    var obj = document.getElementById("obj");
    var opt = document.getElementById("opt");
    var rct = document.getElementById("rct");
    var result;
    try{
        if(rct.value != '' && rct.value != null){
            result = sforce.connection.describeLayout(obj.value, new Array(rct.value));        
        }else {
            result = sforce.connection.describeLayout(obj.value);
            alert(result);
            alert('please note that you have not provided record type id. if the object has more than one record type and different page layout assignments, you will get the code with all the page layouts');
        }
        //call methods edit or details
        if(opt.value == 'Edit')editLayoutResults(result, obj);
        else detailLayoutResults(result, obj);
    }catch(error){      
        var er = new String(error);
        if(er.indexOf('INVALID_TYPE') != -1)alert('please check object api name');
        document.getElementById("{!$Component.hide}").value = '';
    }
}


//edit*****************************************layout
function editLayoutResults(result, obj) {
    output = '';
    var layouts = result.getArray("layouts");

    output += '<' + 'apex' + ':' + 'page standardController=' + '"' + obj.value + '"' + '>';
    output += '\n';
    output += '<' + 'apex' + ':' + 'sectionHeader' + ' title=' + '"' + obj.value + ' Edit' + '"' + ' subtitle=' + '"' + '{' + '!' + obj.value + '.name}' + '"' + '/>';
    output += '\n';
    output += '<' + 'apex' + ':' + 'form' + '>';
    output += '\n';
    output += '<' + 'apex' + ':' + 'pageBlock title=' + '"' + obj.value + ' Edit' + '"' + ' mode=' + '"edit">';
    output += '\n';
    output += '\n';
    output += '<' + 'apex' + ':' + 'pageBlockButtons location=' + '"top">';
    output += '\n';
    output += '<' + 'apex:commandButton value=' + '"' + 'Save' + '" ' + 'action=' + '"' + '{' + '!' + 'save' + '}"' + '/>';
    output += '\n';
    output += '<' + 'apex:commandButton value=' + '"' + 'Save & New' + '"' + ' action=' + '"' + '{' + '!save}" />';
    output += '\n';
    output += '<' + 'apex:commandButton value="Cancel" action=' + '"' + '{' + '!cancel}' + '"/>';
    output += '\n';
    output += '<' + '/apex:pageBlockButtons>';
    output += '\n';
    output += '\n';
    output += '<' + 'apex' + ':' + 'pageBlockButtons location=' + '"bottom">';
    output += '\n';
    output += '<' + 'apex:commandButton value=' + '"' + 'Save' + '" ' + 'action=' + '"' + '{' + '!' + 'save' + '}"' + '/>';
    output += '\n';
    output += '<' + 'apex:commandButton value=' + '"' + 'Save & New' + '"' + ' action=' + '"' + '{' + '!save}" />';
    output += '\n';
    output += '<' + 'apex:commandButton value="Cancel" action=' + '"' + '{' + '!cancel}' + '"/>';
    output += '\n';
    output += '<' + '/apex:pageBlockButtons>';

   
    //adding fields and sections
    var allTheLayouts = result.getArray("layouts");
    for (var i = 0; i < allTheLayouts.length; i++){
        var layout = allTheLayouts[i];
        if (layout.editLayoutSections != null){
            var elSections = layout.getArray("editLayoutSections");
            for (var j = 0; j < elSections.length; j++){
                var els = elSections[j];
               
                output += '\n';
                output += '\n';
                output += '<' + 'apex:pageBlockSection title=' + '"' + els.heading + '" ' +  'columns=' + '"' + els.columns + '"' + '>';
                output += '\n';

                var allTheLayoutRows = els.getArray("layoutRows");
                for (var k = 0; k < allTheLayoutRows.length; k++){
                    var lr = allTheLayoutRows[k];
                    var lis = lr.getArray("layoutItems");
                    for (var h = 0; h < lis.length; h++){
                        var li = lis[h];
                        //only in case of Lead and Contact First Name, which includes Salutation also
                        if (li.layoutComponents != null && li.layoutComponents.length == 2){                          
                            output += '<' + 'apex:inputField value=' + '"' + '{' + '!' + obj.value + '.' + li.layoutComponents[1].value + '}' + '" ' + 'required=' + '"' + li.required.toString() + '"' + '/>';
                            output += '\n';
                        }
                        //for all other fields
                        else if (li.layoutComponents != null){
                            output += '<' + 'apex:inputField value=' + '"' + '{' + '!' + obj.value + '.' + li.layoutComponents.value + '}' + '" ' + 'required=' + '"' + li.required.toString() + '"' + '/>';
                            output += '\n';
                        }
                    }
                }
                output += '<' + '/apex:pageBlockSection>';
                output += '\n';
            }
        }
    }
    output += '\n';
    output += '<' + '/apex:pageBlock>';
    output += '\n';
    output += '<' + '/apex:form>';
    output += '\n';
    output += '<' + '/apex:page>';
 
    document.getElementById("{!$Component.hide}").value = output;
}


//details**********************************layout
function detailLayoutResults(result, obj) {
    var layouts = result.getArray("layouts");
    var output = '';

    output += '<' + 'apex' + ':' + 'page standardController=' + '"' + obj.value + '"' + '>';
    output += '\n';
    output += '<' + 'apex' + ':' + 'sectionHeader' + ' title=' + '"' + obj.value + '"' + ' subtitle=' + '"' + '{' + '!' + obj.value + '.name}' + '"' + '/>';
    output += '\n';
    output += '<' + 'apex' + ':' + 'pageBlock title=' + '"' + obj.value + '"' + '>';
    output += '\n';
   
    //adding fields and sections
    var allTheLayouts = result.getArray("layouts");
    for (var i = 0; i < allTheLayouts.length; i++){
        var layout = allTheLayouts[i];
        if (layout.editLayoutSections != null){
            var elSections = layout.getArray("editLayoutSections");
            for (var j = 0; j < elSections.length; j++){
                var els = elSections[j];
               
                output += '\n';
                output += '<' + 'apex:pageBlockSection title=' + '"' + els.heading + '" ' +  'columns=' + '"' + els.columns + '"' + '>';
                output += '\n';

                var allTheLayoutRows = els.getArray("layoutRows");
                for (var k = 0; k < allTheLayoutRows.length; k++){
                    var lr = allTheLayoutRows[k];
                    var lis = lr.getArray("layoutItems");
                    for (var h = 0; h < lis.length; h++){
                        var li = lis[h];
                        //only in case of Lead and Contact First Name, which includes Salutation also
                        if (li.layoutComponents != null && li.layoutComponents.length == 2){                          
                            output += '<' + 'apex:outputField title=' + '"' + li.label + '" value="' + '{' + '!' + obj.value + '.' + li.layoutComponents[1].value + '}' + '"' + '/>';
                            output += '\n';
                        }
                        //for all other fields
                        else if (li.layoutComponents != null){
                            output += '<' + 'apex:outputField title=' + '"' + li.label + '" value="' + '{' + '!' + obj.value + '.' + li.layoutComponents.value + '}' + '"' + '/>';
                            output += '\n';
                        }
                    }
                }
                output += '<' + '/apex:pageBlockSection>';
                output += '\n';
            }
        }
    }
    output += '\n';
    output += '<' + '/apex:pageBlock>';  
    output += '\n';
    output += '<' + '/apex:page>';

    document.getElementById("{!$Component.hide}").value = output;
}
</script>

<p><b>Enter the object API Name and record type Id associated to create visualforce code of the page layout for the selected page type.</b></p>

<table>
<tr >
<td><b>Object API Name</b></td>
<td><input type="text" id="obj"/></td>
</tr>

<tr >
<td><b>Record Type Id</b></td>
<td><input type="text" id="rct"/></td>
</tr>

<tr >
<td><b>Page Type</b></td>
<td><select id="opt">
  <option value="Edit">Edit</option>
  <option value="Detail">Detail</option>
</select></td>
</tr>
</table>

<center><apex:commandButton id="but" value="Create Page Code" onclick="setupPage()" action="{!create}" rerender="pan" status="pageStatus"/></center>
<apex:inputHidden id="hide" value="{!hide}"/>

<br><br></br></br>
<apex:actionStatus id="pageStatus" startText="Getting page code..." stopText="Page Code"/>
<table >
<tr>
<td>
<apex:outputPanel id="pan">
{!output}
</apex:outputPanel>
</td>
</tr>
</table>

</apex:form>
</apex:page>




Thursday, January 10, 2013

Searching a Debug Log:


Searching a Debug Log:


 To search for text in a debug log, use the Command Line Window in the Developer Console.
Before you can search a log, you must execute Apex statements to generate a log.
  1. To open the Developer Console Command Line Window, choose Your Name | Developer Console and press CTRL+L.
  2. To execute Apex code and generate a log, do one of the following:
    • To enter Apex statements at the command-line, type exec <Apex statements>.
      For example, type:
      exec List<Account> accts = new List<Account>(); for (Integer i=0; i<20; i++)
      { Account a = new Account(name='Account Name ' + i); accts.add(a); }
      To execute code that already exists in the Execute Apex Code window, type exec -r.
      1. To search for text in the debug log, type find <string>For example, type find Account Name. View the search results in the command-line window.
      2. To close the command-line, press CTRL+L.

Tuesday, January 8, 2013

Lookup Auto Populate:

Lookup Auto Populate:
This example shows how to populate account name lookup on opportunity which depends on another custom lookup which is furthur connected to account.You can try in different by customizing logic part

trigger AccountLookup on Opportunity (before insert, before update) { List<String> AcctNames = new List<String>();  for (Opportunity a:Trigger.new) { AcctNames.add(a.AccountName__c); } List <Account> AcctList = [Select ID from Account where Name in :AcctNames]; for (Integer i = 0; i < Trigger.new.size(); i++) { if (Trigger.new[i].AccountName__c != null)  { Trigger.new[i].Accountid = AcctList[i].ID; } else { Trigger.new[i].Account = null; } } }


              

Monday, January 7, 2013

Mass ReOpen Cases:

Mass ReOpen Cases:
How to reopen cases from list view? It could be done by javascript list view button like this

{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")} 
var records = {!GETRECORDIDS($ObjectType.Case)}; 
var newRecords = []; 
if (records[0] == null) 

alert("Please select at least one row") 

else 

for (var n in records) { 
var c = new sforce.SObject("Case"); 
c.id = records[n]; 
c.Status = "New"; 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 
window.location.reload(); 
}


Sunday, January 6, 2013

Building Templates in Sites.com:

Building Templates in Sites.com:
This is a good example to understand templates use in sites.com.You can download resource Here

<apex:page docType="xhtml-1.0-strict" showheader="false" sidebar="false" standardstylesheets="false">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Defrost  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20111121

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Defrost by FCT</title>
<link href="http://fonts.googleapis.com/css?family=Oxygen" rel="stylesheet" type="text/css" />
<apex:stylesheet value="{!URLFOR($Resource.Defrost, 'style.css')}"/>
</head>
<body>
<div id="wrapper">
    <div id="header-wrapper">
        <div id="header">
            <div id="logo">
                <h1><a href="#">Defrost</a></h1>
                <p>template design by free <a href="http://www.freecsstemplates.org/">FCT</a></p>
            </div>
        </div>
    </div>
    <!-- end #header -->
    <div id="menu">
        <ul>
            <li class="current_page_item"><a href="#">Homepage</a></li>
            <li><a href="#">Blog</a></li>
            <li><a href="#">Photos</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Links</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
    <!-- end #menu -->
    <div id="page">
        <div id="page-bgtop">
            <div id="page-bgbtm">
                <div id="content">
                    <div class="post">
                        <h2 class="title"><a href="#">Welcome to Defrost</a></h2>
                        <div class="entry">
                            <p><apex:image url="{!URLFOR($Resource.Defrost, 'images/pics01.jpg')}" alt="" width="600" height="200"/>This is <strong>Defrost</strong>, a free, fully standards-compliant CSS template designed by  <a href="http://www.freecsstemplates.org">FCT</a>.  The picture in this template is from <a href="http://fotogrph.com/">FotoGrph</a>.This free template is released under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attributions 3.0</a> license, so you’re pretty much free to do whatever you want with it (even use it commercially) provided you keep the links in the footer intact. Aside from that, have fun with it :)</p>
                        </div>
                    </div>
                    <div class="post">
                        <h2 class="title"><a href="#">Lorem ipsum sed aliquam</a></h2>
                        <div class="entry">
                            <p><apex:image url="{!URLFOR($Resource.Defrost, 'images/pics02.jpg')}" alt="" width="600" height="200"/>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer. Donec ipsum. Proin imperdiet est. Phasellus <a href="#">dapibus semper urna</a>. Pellentesque ornare, consectetuer nisl felis ac diam. Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. Mauris vitae nisl nec metus placerat consectetuer. </p>
                        </div>
                    </div>
                    <div class="post">
                        <h2 class="title"><a href="#">Phasellus pellentesque turpis </a></h2>
                        <div class="entry">
                            <p><apex:image url="{!URLFOR($Resource.Defrost, 'images/pics01.jpg')}" alt="" width="600" height="200"/>Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer. Donec ipsum. Proin imperdiet est. Pellentesque ornare, orci in consectetuer hendrerit, urna elit eleifend nunc. Donec ipsum. Proin imperdiet est. Pellentesque ornare, orci in consectetuer hendrerit, urna elit eleifend nunc.</p>
                        </div>
                    </div>
                    <div style="clear: both;">&nbsp;</div>
                </div>
                <!-- end #content -->
                <div id="sidebar">
                    <ul>
                        <li>
                            <h2>Aliquam tempus</h2>
                            <p>Mauris vitae nisl nec metus placerat perdiet est. Phasellus dapibus semper consectetuer hendrerit.</p>
                        </li>
                        <li>
                            <h2>Categories</h2>
                            <ul>
                                <li><a href="#">Aliquam libero</a></li>
                                <li><a href="#">Consectetuer adipiscing elit</a></li>
                                <li><a href="#">Metus aliquam pellentesque</a></li>
                                <li><a href="#">Suspendisse iaculis mauris</a></li>
                                <li><a href="#">Urnanet non molestie semper</a></li>
                                <li><a href="#">Proin gravida orci porttitor</a></li>
                            </ul>
                        </li>
                        <li>
                            <h2>Blogroll</h2>
                            <ul>
                                <li><a href="#">Aliquam libero</a></li>
                                <li><a href="#">Consectetuer adipiscing elit</a></li>
                                <li><a href="#">Metus aliquam pellentesque</a></li>
                                <li><a href="#">Suspendisse iaculis mauris</a></li>
                                <li><a href="#">Urnanet non molestie semper</a></li>
                                <li><a href="#">Proin gravida orci porttitor</a></li>
                            </ul>
                        </li>
                        <li>
                            <h2>Archives</h2>
                            <ul>
                                <li><a href="#">Aliquam libero</a></li>
                                <li><a href="#">Consectetuer adipiscing elit</a></li>
                                <li><a href="#">Metus aliquam pellentesque</a></li>
                                <li><a href="#">Suspendisse iaculis mauris</a></li>
                                <li><a href="#">Urnanet non molestie semper</a></li>
                                <li><a href="#">Proin gravida orci porttitor</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <!-- end #sidebar -->
                <div style="clear: both;">&nbsp;</div>
            </div>
        </div>
    </div>
    <!-- end #page -->
</div>
<div id="footer">
    <p>Copyright (c) 2012 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/">FCT</a>. Photos by <a href="http://fotogrph.com/">fotogrph</a>.</p>
</div>
<!-- end #footer -->
</body>
</html>
</apex:page>

Emoticons to a chat:

Emoticons to a chat:

Typing certain combinations of letters and punctuation marks inserts a whimsical icon into your chat conversation.
Available in: GroupProfessionalEnterpriseUnlimitedContact Manager, and Developer Editions

The following emoticons are available.
EmoticonTyped Characters
Happy face:-):):]=)
Sad face:-(:(:[=(
Wide Grin:-D:D=D
Shocked face:-O:O:-o:o
Face with tongue sticking out:-P:P:-p:p=P
Wink;-);)
Puzzled face:/:-/:\:-\
You can turn off emoticons in Chat | Grey gear | Options.