• dmsx2od
  • 75 Points
  • Member since 2008

  • Chatter
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
  • 42

 The trigger below gets the days between the created date and actvity date and puts the results in the day_count__C field. However, my test method below is still at 0%. Any help would be grealy appreciated.


trigger Event_Before_Insert on Event (before update)

for( Event currentEvent : Trigger.new )
datetime CreatedDate =CurrentEvent.CreatedDate;
date ActivityDate =CurrentEvent.ActivityDate;

date createdDateTemp = date.newInstance(CreatedDate.year(),CreatedDate.month(),CreatedDate.day());
Integer numberofDays = createdDateTemp.daysBetween(ActivityDate);

CurrentEvent.Day_Count__c = numberofDays;






The test method below keeps saying 0 percent.





            Event ev48 = new Event(Subject = 'Test', Type= 'Other', Meeting_Status__c = 'Pending',ActivityDate =Date.today(),WhoId = cont.Id );
try {
insert ev48;
catch(DmlException e) {
ev48.day_count__c= 0;
update ev48;



In the Org I'm currently working with, they have Person-Accounts enabled.


In Person-Accounts, "email" is a valid field in the Account object.  I've been able to use the email field in Page layouts, and update the field via the standard UI -- but I am unable to query or write to the field in Apex.


Instead, I get an error message that "email" is not a recognized field for the Account object:



Is there a method for accessing the "email" field on Person-Accounts?

Is there a way to populate a Multi-Picklist from a query when the page layout is rendered?


Thank you,




I had a problem with a page not showing, and it turns out that my mistake was how I declared the page template. 


I had: <apex:composition template="{!$Page.SiteTemplate}">


But I should have had: <apex:composition template="{!$Site.Template}">


Don't make my mistake!  Page.SiteTemplate is visible from inside the app, but not from the Site.  Site.Template, however, is visible inside and outside.

I noticed that in Page.SiteRegisterConfirm, there is a line <c:SiteFooter /> but in Page.SiteTemplate there is also <c:SiteFooter />.


It seems to me that the one in Page.SiteRegisterConfirm is extraneous, as the page already has a reference to  <apex:composition template="{!$Site.Template}">.


Am I missing something?  If not, I'm going to delete all SiteFooter references from the pages themselves and allow the site template to handle that.


What does everyone think?

All- I may have found a bug in the "inline visualforce in page layouts" feature.  Please read what I did and try to reproduce the error.  Thank you.


  1. Make VF page with the following code: 

    <apex:page standardController="Account">

  2. Put it in an Account page layout
  3. Change the VF standardController to "Contact" - DO NOT remove it from the page layout first
  4. View an Account - note that the inline VF page displays correctly
  5. Edit the Account page layout - I did it from the Setup menu and from the "Edit Layout" link
  6. Note that the layout editor hangs with a yellow "Loading..." status
  7. Change the VF standardController back to "Account"
  8. Verify that the page layout editor works properly

Though this is something that no smart admin would do (please don't ask how I found this), we should account for any usage of the tool.

Can others reproduce this behavior? 




I have this trigger to copy the new owner's last name to the Account site (using standard fields instead of custom ones for simplicity):


trigger accountOwnerSalesID on Account (before insert, before update) {
Set<ID> UserIDs = new Set<ID>();
for(Account a : Trigger.New){
map<ID, String> usermap = new map<ID, String>();
for (User u:[SELECT id, LastName FROM User WHERE id in: UserIDs]){
usermap.put(u.id, u.LastName);
for(Account acct: Trigger.New){
acct.Site = usermap.get(acct.OwnerID);

 And my test code:


private class testAccountOwnerSalesID {
static testMethod void myUnitTest() {
ID runningID = UserInfo.getUserID();
User ouruser = [SELECT id, LastName FROM User WHERE id =: runningID LIMIT 1];
String userlastname = ouruser.LastName;
system.debug('userlastname: ' + userlastname);
Account acct = new Account(name='acct1');
insert acct;
system.debug('acct site: '+ acct.Site);
system.assertequals(userlastname, acct.Site);
update acct;
system.debug('acct site: '+ acct.Site);
system.assertequals(userlastname, acct.Site);

But my assertequals statements fail.  The system says that the Site is null.  But when I create & update an Account in the UI, it works flawlessly for both.

What am I missing?





Hi all - I'm experimenting with using Components as data editors.


Use case:

1. In the detail (view) page layout for a Contact, show a component with its own save button.  (This is sorta like inline editing.)

2. Allow the component to display and edit any phone field on the object.  So, for instance, it could show HomePhone, OtherPhone, etc.


Do I need to pass the field value as a string {!Contact.HomePhone} AND pass the field name "Contact.HomePhone" so it can not only display the value, but also write to the Contact?


It looks like I may also need to change the attribute (string 'Contact.HomePhone') to a field so I can type 

Contact.HomePhone = '(212) 555-1212';

Any advice on doing that? It seems I may need to do a describe, and then get the field token.




I've got a trigger that is so simple that I can't find a reason why it wouldn't work - and the debug statements show the proper values - but nothing happens when I save the account:



trigger accountFillSite on Account (before insert, before update) { for (Account a: [select id, Site, BillingCity, BillingState FROM Account WHERE id IN :Trigger.New]){ System.Debug('Account Site is ' + a.Site + ' City: '+a.BillingCity+' State: '+a.BillingState); a.Site = a.BillingCity + ', ' + a.BillingState; system.debug('a.Site: '+a.Site); } }

I'm baffled as to why this won't work. 

At this point, I'm less concerned with whether or not I'm using proper technique, and more concerned with it working on one record at a time.  I edit the record, and click Save. 

All field permissions are set appropriately.  Debug logs show all values set properly.  Even the last debug line, a.Site, shows the expected value.





Hi members.. i have a question about developing apex code in salesforce. i am a fresher completed my masters in management. i trained in salesforcce as admin and developer. but i am worrying about developing apex code for a real time project.could you please tell me what percent of code is written by developers as own and what percent of code will be available from the sources like forums, google, importing the existindg code...... etc.


waiting for the responses from all




I followed the instructions to create a report that pulls in the Company Name as a parameter. The report works fine, except for companies that end in ", Inc." or ", LLC", etc.


For some reason, the parameter removes the space between the comma and "Inc", so that no results are returned. Any ideas on how to correct this?





  • February 21, 2010
  • Like
  • 0

COMSYS is in search of a Salesforce.com Developer.  This person will be more of a coder than a configurator.  The job details are as follows:



Title: SFDC Developer

Duration: 1-2 months


Location:  Seattle, WA

Key Responsibilities:

-Assist in managing the SF instance using the standard aspects of the Salesforce Setup menu.
-Create and manage custom objects, fields, and formulas.
-Develop and maintain custom reports.
-Develop and maintain dashboards.
-Develop and maintain validation rules and custom workflow.
-Audit, uncover and resolve data integrity issues.
-Complete bulk imports of data.
-Batch reassignment of accounts and opportunities based on organizational changes.
-Prepare training materials for business use.
-Recommend best practices.
-Recommend, implement, test, and deploy Visualforce pages.
-Recommend, implement, test, and deploy Apex classes and triggers.


-4+ years experience with Salesforce.com development.
-Bachelors degree in business or technology field or equivalent work experience.
-Well organized.
-Flexibility to meet continuously changing priorities and challenges.
-Intermediate/Advanced Excel capabilities and related data manipulation a plus.
-Solid communication and interpersonal skills.
-Experience with Apex and/or Visualforce development required.
-Experience with report writing software a plus.


For immediate consideration please contact Sharonda Birt at sbirt@comsys.com.


  • January 22, 2010
  • Like
  • 0
Are you looking for Salesforce.com & Force.com customizations or development services?
Do you have any upcoming projects that would require a Salesforce expert?
Don't worry now. Just send an email at sfdcmaster@gmail.com
Here is what I can do for you.

* Customize and personalize Salesforce.com to fit environment's specific needs.
* Create new user accounts and configure Salesforce.com to fit security needs at the user and organization levels.
* Creation & implementation of Custom Objects, Custom Apps, Page Layouts, Related Lists, Tabs, Validation Rules, Workflow Rules, Sharing Rules, Outbound/Inbound Messages
* Lead, Account, Opportunity Managements
* Lead Conversion process, email-to-case, web-to-lead implementations
* Generate different kind of reports & dashboards
* Development using Visualforce pages, Apex classes, S-controls, Triggers, Webservices, Javascript, Ajax
* Code optimization w.r.t. governor limits of salesforce
* Data migration and manipulation using Salesforce tools
* Unit tests code coverage and deployments
* Integration using salesforce APIs
* Portals setup & appExchange package deployment
* Force.com sites development

These services are available in just $20 USD per hour. For more information just send an email at sfdcmaster@gmail.com
Message Edited by SFDC Expert on 01-19-2010 10:06 PM
I'm looking for help on how to tackle this need: we want to trigger the addition of several AEs to the sales team (all partner users) of an opportunity when their partner account is added as a partner to the opportunity. I'm completely stuck. Any ideas?

Hello Friends,

How do i store attachments using APEX,i am using the tag inputfile in visual force,but against

which object type do i store it against.



I'm trying to use sites to post a web-to-lead form for tradeshows.  I'm using the HTML generated by Salesforce, with some additional coding to make it look nice.  I tried posting on Sites, but the editor keeps giving me error messages.  I corrected most of them, but the editor does not like my <input> html tags. 


Is there no way to use html web coding in Sites?  I have not worked at all with Apex/Visualforce.



Hi Guys,


I have 2 picklists on Account. One is "Industry" -- controlling field, the other is "Sector" -- dependent field.

For example,


When I choose "IT" for Industry, the Sector will show Database, CRM sys, NetWork etc.

When I choose "Education" for Industry, the Sector will show something .....

all those above are set up in field definition in Setup.


I wonder whether there is a way to get their relationship. I mean I hope Apex can help  show which picklist value in industry controlls which values in Sector.





Any idea will be goooooooooooooooooooood!!

Hi -


I am looking for the fastest way possible to mass delete all records for a given custom object. I developed a very simple Batch Apex class which is described below.  The code works but it performs very slowly. Yesterday it took 40 minutes to delete 34,000 records, although I did not run into any governor limits.  It seems that the execute() call is only receiving a few records at a time.  Is there any way to coax it to process large groups of records?


Any help would be greatly appreciated.


global class MassDeleteCustomObject implements Database.Batchable<Sobject>


  global final String query = 'select Id from <my custom object>';


  global Database.QueryLocator start(Database.BatchableContext BC)



       return Database.getQueryLocator(query);



    global void execute(Database.BatchableContext BC, List<Sobject> records)


        delete records;



  global void finish(Database.BatchableContext BC)





PerForceApps is the first and only company dedicated to building applications on the Force.com platform.

Whether you are building a new business application from scratch or you want to integrate salesforce.com with your existing products or services to list on the AppExchange, we can help. The advantages of using the Force.com platform include:


* Cost effective way of exposing your products and services to more than 50,000 new prospects
* Faster time to market and lower cost of development than other platforms
* Lower up front costs, pay as you add customers, and automatically scalable and reliable
* Give your current customers new ways to interact with your products and services


To learn more please call Michael directly at (415) 680-3162.




How do I add this to my page layout? I want to be able to create a custom button or link on the contact page layout so that when I click it, it brings up all the related activities for that contact record using the query below. When I try to select this in the page layout nothing shows up under content. How can I select the vf page i created?





<apex:page controller="ActivityController">
<apex:pageBlock >
<apex:pageBlockTable value="{!Activities}" var="a">
<apex:column value="{!a.subject}"/>
<apex:column value="{!a.type}"/>
<apex:column value="{!a.ownerid}"/>
<apex:column value="{!a.whoid}"/>
<apex:column value="{!a.whatid}"/>
public class ActivityController

public Event[] getActivities()

list<Event> lstEvent = [Select id, subject,whatid, whoid, type, activitydate,ownerid from Event where id = :ApexPages.currentPage().getParameters().get('whoid')];
return lstEvent;


Message Edited by bikla78 on 08-03-2009 08:48 PM

 The trigger below gets the days between the created date and actvity date and puts the results in the day_count__C field. However, my test method below is still at 0%. Any help would be grealy appreciated.


trigger Event_Before_Insert on Event (before update)

for( Event currentEvent : Trigger.new )
datetime CreatedDate =CurrentEvent.CreatedDate;
date ActivityDate =CurrentEvent.ActivityDate;

date createdDateTemp = date.newInstance(CreatedDate.year(),CreatedDate.month(),CreatedDate.day());
Integer numberofDays = createdDateTemp.daysBetween(ActivityDate);

CurrentEvent.Day_Count__c = numberofDays;






The test method below keeps saying 0 percent.





            Event ev48 = new Event(Subject = 'Test', Type= 'Other', Meeting_Status__c = 'Pending',ActivityDate =Date.today(),WhoId = cont.Id );
try {
insert ev48;
catch(DmlException e) {
ev48.day_count__c= 0;
update ev48;



I am just starting out with Visual Force, but want to make sure I handle localization appropriately. I created a very simple VF example below, where I'm trying to redefine the Account home tab.


I'm hoping someone can show me how to access "standard" SFDC text values so that I do not have to create "Custom Labels" to  handle localization. I am not talking about standard object field names, because you can see below I can access localize fields without issue. I want to access text values that SFDC has already localized in their application ... i.e. View, Home, Go!, Search, Setup, Help, Logout, etc.  Not that I need all of these, but if I want to put the text "Home" on my VF page, why not leverage what SFDC has already localized?


You can see in my example below, the items highlighted in "Red" I created as "Custom Labels" and the "Go!" value is just hard-coded.


Any help is greatly appreciated!




<apex:page standardController="Account" recordSetVar="accounts">
<apex:sectionHeader title="{!$ObjectType.Account.Label}" subtitle="{!$Label.Home}" />
<apex:form >
<apex:outputLabel >
<apex:selectList value="{!filterid}" size="1">
<apex:selectOptions value="{!listviewoptions}"/>
<apex:commandButton value="Go!" action="{!list}"/>



Is it possible to write a class that extends a custom VF controller, and then use the new class as the controller for a page?  Can I extend a class that is itself an extension of a standard controller, as opposed to a fully-custom controller?


It's the latter that I'm trying to do right now.


I tried creating an extension.  I added the "virtual" keyword to my existing controller, then defined a new child class something like so:


public class CTRL_CustomWizard extends CTRL_FooWizard {


 but I get the error "Parent class has no 0-argument constructor for implicit construction"



 Does this mean I can't do it, or do I need to do something else?  The constructor in the parent class can't have no arguments, because it's an extension of a standard controller, so the constructor is defined like:


public CTRL_FooWizard (ApexPages.StandardController controller) {


Thanks much!


Message Edited by sparky on 05-28-2009 10:50 PM

I have a few once active approval process that, when deactivated, I cannot delete.  Is there a way to delete these old approval processes or are they going to be stuck in my salesforce org forever?  I've tried removing the records that have approval history but with no success.


Any help would be appreciated on this.

Whe I convert a lead to a contact, the email address default to work.  Is there a way to have it default to home?

We have an opp with item lines as follows


Product X

Product Y

Product Z


We print it using the PDF rendered in VF and it outputs in a seemingly "random" order


Product Y

Product Z

Product X


Is this a known issue -- is there any way of working around this problem? ***Ideally*** what we wouild love to be able to do is grouped items e.g ...



2 x $500.00   Programming    $1000.00 

3 x $500.00   Testing             $1500.00  



12 x $10.00   12 Months Hosting       $120.00   

12 x $1.00     12 Months Domain Reg $12.00    

i'm new to writing s-controls and I'm trying to accomplish the following.  I want to create a link (custom link) and when the custom link is clicked it opens a new window and calls a custom s-control.
If there are any examples that explain how to accomplish this, it would be greatly appreciated.
thank you.