Wednesday, July 22, 2009
How to Calculate the Number of Days in a Month
Monday, July 20, 2009
Displaying Running Digital Clock
The technical support / customer service will raise a case on behalf the account user and follow up the case,
Whenver the technical support try to reach the case contact he/she want to know the current time of case contact.
So i have decided to display the running digital clock in case detail page:
some thing like this...
sceern shot of case detail page :
Step 1: Create a Picklist field in contact called TimeZone__c with field values like ...
<table bgcolor="#c9c299">
<th><apex:image value="{!$Resource.hand}"/></th>
<th><apex:outputText value="Your Time " /></th>
<th width="5"></th>
<th>
<apex:image id="Uh1" value="{!h1}"/>
<apex:image id="Uh2" value="{!h2}"/>
<apex:image id="Um" value="{!$Resource.dgc}" />
<apex:image id="Um1" value="{!m1}"/>
<apex:image id="Um2" value="{!m2}"/>
<apex:image id="Us" value="{!$Resource.dgc}"/>
<apex:image id="Us1" value="{!s1}"/>
<apex:image id="Us2" value="{!s2}"/>
<apex:image id="Uampm" value="{!ampm}" />
<apex:actionPoller action="{!UserTime}"
rerender="Uh1,Uh2,Us1,Us2,Um1,Um2,Uampm,r1" interval="5" />
</th><th width="120" ><apex:outputText value="{!a}" id="r1" /></th>
<th><apex:image value="{!$Resource.hand}"/></th>
<th><apex:outputText value="Contact Time " /></th>
<th width="5"></th>
<th>
<apex:image id="Ch1" value="{!h1}"/>
<apex:image id="Ch2" value="{!h2}"/>
<apex:image id="Cm" value="{!$Resource.dgc}"/>
<apex:image id="Cm1" value="{!m1}"/>
<apex:image id="Cm2" value="{!m2}"/>
<apex:image id="Cs" value="{!$Resource.dgc}"/>
<apex:image id="Cs1" value="{!s1}"/>
<apex:image id="Cs2" value="{!s2}"/>
<apex:image id="Campm" value="{!ampm}" />
<apex:actionPoller action="{!ContactTime}"
rerender="Ch1,Ch2,Cs1,Cs2,Cm1,Cm2,Campm,Cr1" interval="5" />
</th><th width="120" ><apex:outputText value="{!a}" id="Cr1" /></th>
</table>
</apex:form>
</apex:page>
Apex Class:
public with sharing class contact_clock {
public contact_clock(ApexPages.StandardController controller) { }
String idr = System.currentPageReference().getParameters().get('id');
string urlr = 'https://na5.salesforce.com/resource/1246944823000/dg';
DateTime tall; Boolean flag; String temp,tempw,temph,tempm,sDate,ap,s1,s2,m1,m2,h1,h2,dt;
Public PageReference UserTime() {
flag = false; geta(); return null;
}
Public PageReference ContactTime() {
flag = true; geta(); return null;
}
public string geta() {
tall = Datetime.now();
if(flag == true){
contact con2 = [select TimeZone__c from contact where id in (select contactid from case where id=:idr)];
tempw = con2.TimeZone__c.substring(4,5);
if(tempw == '+'){temph = con2.TimeZone__c.substring(5,7);}else{
temph = con2.TimeZone__c.substring(4,7);
}
integer addh = integer.valueof(temph);
tempm = con2.TimeZone__c.substring(8,10);
integer addm = integer.valueof(tempm);
datetime newDateh = tall.addHours(addh);
datetime newDatem = newDateh.addminutes(addm);
sDate = newDatem.formatgmt('hh:mm:ss a MM-dd-yyyy');}else{
sDate = tall.format('hh:mm:ss a MM-dd-yyyy');}
s2 = sDate.substring(7,8);
s1 = sDate.substring(6,7);
m2 = sDate.substring(4,5);
m1 = sDate.substring(3,4);
h2 = sDate.substring(1,2);
h1 = sDate.substring(0,1);
ap = sDate.substring(9,11);
dt = sDate.substring(11);
return dt;
}
public string gets1() {
return urlr+s1;
}
public string gets2() {
return urlr+s2;
}
public string getm1() {
return urlr+m1;
}
public string getm2() {
return urlr+m2;
}
public string geth1() {
return urlr+h1;
}
public string geth2() {
return urlr+h2;
}
public string getampm() {
return urlr+ap;
}
}
Monday, June 15, 2009
Understand the structure of all the URLs in Salesforce
Important notes on the URLs in Salesforce:
To find out what instance you’re on, once you logged into Salesforce, have a look at the address bar;
You’ll notice the URL starts with something like:
na1 -
na2 -
na3 -
na4 -
na5 -
emea - Europe, Middle East,
ap -
cs2 - Sandbox #1
cs3 - Sandbox #2
Where xyz is the name of the instance your organization is on.
Objects | Objects’ code |
Accounts | 001 |
Contacts | 003 |
Users | 005 |
Leads | 00Q |
Cases | 500 |
Solutions | 501 |
Reports | 00O |
Opportunities | 006 |
Campaigns | 701 |
Products | 01t |
Setup | Objects’ code |
Setup | |
Apps | 02u |
Custom Labels | 101 |
Packages | 033 |
Workflow Rules | 01Q |
Tasks | 01V |
Email Alerts | 01W |
Field Updates | 04Y |
Outbound Messages | 04k |
Apex Classes | 01p |
Static Resources | 081 |
Sites | 0DM/o |
S-Controls | 01N |
Home Page Layouts | 02T |
All Custom Report Types | 070 |
Visualforce Pages | 066 |
Email Templates | 00X |
Letterheads | 016 |
Mail Merge Templates | 01H |
Analytic Snapshots | 0A0 |
Approval Processes | p/process/ProcessDefinitionSetup? |
Email Services | email/admin/listEmailServicesFunction.apexp? |
Visualforce Components | apexpages/setup/listApexComponent.apexp? |
Roles | setup/user/roleSplash.jsp? |
Profiles | setup/ui/profilelist.jsp? |
Public Groups | p/own/OrgPublicGroupsPage? |
Queues | p/own/OrgQueuesPage? |
Sharing Settings | p/own/OrgSharingDetail? |
Company Information | your org id |
Storage Usage | setup/org/orgstorageusage.jsp?id=your org id |
Debug Logs | p/setup/layout/ApexDebugLogEdit? |
Triggers | p/setup/layout/ApexTriggerList?type=Account |
Contact Page Layout | ui/setup/layout/PageLayouts?type=Contact |
Search Layouts | ui/setup/layout/ListLayouts?type=Account |
Record Types | ui/setup/rectype/RecordTypes?type=Account |
Basic action URLs
https://[instance].salesforce.com/[Objects’ code]/o
ie: https://emea.salesforce.com/001
https://[instance].salesforce.com/[Objects’ code]/e
ie: https://emea.salesforce.com/001/e
https://[instance].salesforce.com/[recordID]/e
ie: https://emea.salesforce.com/0037000000g9mK4/e
https://[instance].salesforce.com/[recordID]/e?clone
https://[instance].salesforce.com/setup/own/deleteredirect.jsp?delID=[recordID]