• DTCF
  • NEWBIE
  • 55 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 22
    Replies

Hi there, I've written a trigger that sends an email based upon a new opportunity. Trigger works great. Now for the test classes. I've got this test class:

public class testEmailTrigger {
	//This class is simply to test the SendEmailTrigger trigger
	
	//Test Method
	static testMethod void testEmail {
		//Insert a record into the right table to test
		//In this case, the table is Opportunity

		Opportunity o = new Opportunity ();
		o.Amount='100';
		o.CloseDate = System.Today();
		o.Description = 'TEST';
		
		//Start the test
		test.startTest();
		insert o;
		test.stopTest();
	}

}

It complains at the line "Opportunity o = new Opportunity(); with the error "unexpected token Opportunity." What am I doing wrong?

We need a Force.com and VisualForce developer to start immediately. This is maintaining and enhancing an internal Force.com application for a leading interactive agency.

 

Please call   (415) 690-7242

 

if you are highly qualified and interested.

  • November 02, 2010
  • Like
  • 0

I'm fairly confused about all of the different Profile options and how it interacts with Chatter. It seems that it's possible to get Sites to work with Chatter based on this thread:

 

http://community.salesforce.com/t5/Chatter-Development/Chatter-and-Site-Chatter-and-Customer-Portal/m-p/176745

 

but it's entirely unclear to me what Profile should be selected in order to enable this. I setup my Site to use Customer Portal, and I have tried every combination of registering a new user with all of these "user licenses":

 

Authenticated Website

Customer Portal Manager

High Volume Customer Portal

 

In each case, when I try to access the "currenstatus" field on User, it throws an error.

 

Can someone please send me in the right direction?

 

Thanks!

  • August 03, 2010
  • Like
  • 0

We need some help with some bug fixing in Apex. We have a couple of small *but very difficult* bugs that we need help fixing. We do have numerous other projects and other work where we could also use assistance after addressing these bugs. Please only respond if you or your firm have deep technical experience solving very challenging issues in Apex.

 

Please email david@causelabs.com

  • July 27, 2010
  • Like
  • 0

Hello,

 

I cross posted this to Force.com sites, not exactly sure where it belongs. This is highly urgent as I have a deadline for a demo and can't really have a site that doesn't send emails upon user creation/registration.

 

This functionality was working fine, and then it stopped for some reason, I think after I tried editing the standard new user template for Customer Portal (which btw, wasn't getting picked up...does that have to be an additional parameter in the user creation in Apex?)

 

Any reason why this would be the case? Could this be related to a weird dev org limitation? It was working fine with this code inserting a new user:

 

 

	dmo.EmailHeader.triggerUserEmail = true;
		
    	User u = new User(alias = 'newu', email=email, 
            emailencodingkey='UTF-8', lastname=lastname, languagelocalekey='en_US', 
            localesidkey='en_US', profileid = profileId, contactId=contactId, 
            timezonesidkey='America/Los_Angeles', username=username);
        
        u.setOptions(dmo);
        insert u;

 

 

Now, the user is created correctly with the correct email address, but the triggerUserEmail is never sent. If I go into the user and hit the "Reset Password" button, everything works fine as if the user received the email automatically.

 

I'd appreciate if anyone has any thoughts as to why this might be happening. Thanks so much!

  • July 21, 2010
  • Like
  • 0

Hello,

 

Any reason why this would be the case? Could this be related to a weird dev org limitation? It was working fine with this code inserting a new user:

 

 

	dmo.EmailHeader.triggerUserEmail = true;
		
    	User u = new User(alias = 'newu', email=email, 
            emailencodingkey='UTF-8', lastname=lastname, languagelocalekey='en_US', 
            localesidkey='en_US', profileid = profileId, contactId=contactId, 
            timezonesidkey='America/Los_Angeles', username=username);
        
        u.setOptions(dmo);
        insert u;

 

 

Now, the user is created correctly with the correct email address, but the triggerUserEmail is never sent. If I go into the user and hit the "Reset Password" button, everything works fine as if the user received the email automatically.

 

I'd appreciate if anyone has any thoughts as to why this might be happening. Thanks!

  • July 21, 2010
  • Like
  • 0

I have a lead that is created through a Salesforce Site, so that the owner of the lead is the Site Guest User. When I try to convert the lead from a regular user, I get the error:

 

Transfer Requires Read: The new owner must have "Read" permissions on this type of record.

 

I'm using my own user when I'm trying to convert the lead, and my user definitely has Read access to Leads. Not really sure what is going on since the error is so vague. Any insights would be most appreciated.

  • July 16, 2010
  • Like
  • 0

I am 99.9% sure I have set access control correctly. The page displays, but for some reason it will not display/render an <apex:inputField>. Nothing shows up at all. Doesn't throw an error, it just seems to be ignoring any and all <apex:inputField>'s. Any ideas? This is all under a testing dev org. Thank you!

  • July 09, 2010
  • Like
  • 0

I am trying to create a dynamic picklist in a datatable. The issue I'm having is that I need to set the default value of the picklist, and I need to be able to store the value of whatever it is changed to, which will be bound to some variable in a list.

 

To accomplish this I created a new field on the object I'm using (called Vendor), called "selected_vendor__c":

 

 

<apex:column headerValue="Vendor">

     <apex:selectList value="{!i.selected_vendor__c}" size="1" required="true" >
     <apex:selectOption itemValue="" itemLabel=""/>
     <apex:selectOptions value="{!VendorList}"/>
     </apex:selectList> 
                
</apex:column> 

 

All that I'm trying to accomplish is to have the value in the picklist pre-set to whatever the value of "selected_vendor__c" is (which I set dynamically in the list that creates "i"). It doesn't seem to be reflecting this value in the dropdown list.

 

 

Furthermore, I'm hoping that it will also save the value to the List I have in the controller. I've only ever set the value of a picklist to a single variable.

 

Thanks!

  • July 09, 2010
  • Like
  • 0

The subject kind of says it all. I can add an "oncomplete" attribute to the actionfunction that will execute some javascript, but the <apex:repeat> tag I have inside the <apex:facet name="stop"> does not.

 

Can anyone suggest why this might be the case? Is there another way to go about this where I could render some VF code upon completion of an ajax call?

 

Thanks!

  • July 08, 2010
  • Like
  • 0

 

     List<Task> histories = [Select id,Ownerid,whatid,whoid,activitydate,subject,website__c From Task where (whatid=:relatedLink.id and Ownerid=:currentUser and Status='Not Started') limit 1]; 

 

 

 

I'm getting an exception when deploying that is telling me  "Too many query rows: 501".

 

Doesn't the "Limit 1" take care of this??

 

Thanks!

  • July 06, 2010
  • Like
  • 0

I'm seeing curious behavior out of the Salesforce BCC email functionality.

 

When using syntax such as:

 

String userEmail = 'user@email.com';

 

    mail.setBccAddresses(new String[] { userEmail });

 

or


    mail.setBccSender(true);

 

It doesn't seem to BCC to emais where the address is the address of the current Salesforce user.

 

Is this by design? I've tried it with numerous other email addresses where they do not correspond to emails owned by a Salesforce user.

 

Thanks!

  • June 19, 2010
  • Like
  • 0

I'm trying to set a custom field on a task that gets associated with a sent email:

 

mail.setSaveAsActivity(true);

 

How can I get a handle on that Task so that I can set the value of a field dynamically?

 

I was thinking that I could create a "hidden" field on the parent object that gets associated with the "whatid", and then add a trigger on a task, where it looks at its parent object. Would that work?

 

Thanks!

  • June 16, 2010
  • Like
  • 0

I need to get all field values from an Object and dynamically add them to a Map with the name of the field as the key. I can get the field names with a describe, and query all fields by appending them to a comma separated string and then using that string in my SOQL query, but I don't know how to iterate through all fields and add them to a map.

 

The reason why I need to do this is that I want to be able to get the values from the Object dynamically rather than having to explicitly reference a field name. They will all be strings, so I don't have to worry about that.

 

Instead of String value =  CustomObject.Field_One__c;

 

I would like to do map.get('Field_One__c')

 

Something like that. I don't know how to iterate over all field names in the first place and construct the map. Thank you in advance!

  • June 09, 2010
  • Like
  • 0

Is it possible to create an HTML Email Status when sending emails From Apex through the Messaging.sendEmail() method?

  • May 22, 2010
  • Like
  • 0

I'm looking to enable sending up to 100 custom, unique emails at a time, including unique subject lines. The body of the email and the subject need to be set dynamically (based on previous emails, for example, or based on text in the response email), so I'm not sure a template can work, since it would require creating a template programmatically.

  • May 21, 2010
  • Like
  • 0

 

I have an object A with a lookup field to another object B.  There are approximately 500 records of object A in the database. I want to populate that lookup field in those existing records with the appropriate record relationship to Object B. Object B already has a lookup field to object A, so I need to check to see if Object B looks up to Object A, and if it does, I need to associate that record to Object A.

 

 

This is already inside an @future call. I'm getting the too many script statements error. Any advice would be most appreciated!

 

  @future
    public static void addCurrentRPPA() {
        
        
        Active_Project__c[] projects = [select id,name from Active_Project__c];
        
        Active_Project__c[] updateProjects = new Active_Project__c[0];
        
        for (Active_Project__c proj:projects) {
            
            String projId = proj.id;
            
            
            Rate_Profile_Project_Assignment__c rp;
            
            for (Rate_Profile_Project_Assignment__c rate:rateAssignments) {
            
            if (rate.Projects__c==proj.id) {
                rp = rate;
            }            
            
            
            
        }
        
            if (rp!=null) {
            
            proj.rate_profile_project_assignment__c = rp.id;
            updateProjects.add(proj);
            }
            
        }
        
        update updateprojects;
        
    }

 

 

  • April 05, 2010
  • Like
  • 0

Will an "onUpdate" trigger fire on a parent object when a new child record is inserted? Is there anyway to prevent that from happening? I'm getting self-reference problems when I want to insert a new record under some circumstances, but I specifically do not need or want the trigger of the parent object to fire.

 

Thanks!

  • April 02, 2010
  • Like
  • 0

I'm fairly confused about all of the different Profile options and how it interacts with Chatter. It seems that it's possible to get Sites to work with Chatter based on this thread:

 

http://community.salesforce.com/t5/Chatter-Development/Chatter-and-Site-Chatter-and-Customer-Portal/m-p/176745

 

but it's entirely unclear to me what Profile should be selected in order to enable this. I setup my Site to use Customer Portal, and I have tried every combination of registering a new user with all of these "user licenses":

 

Authenticated Website

Customer Portal Manager

High Volume Customer Portal

 

In each case, when I try to access the "currenstatus" field on User, it throws an error.

 

Can someone please send me in the right direction?

 

Thanks!

  • August 03, 2010
  • Like
  • 0

I'm trying to use system.debug() thdisplay the number of records my trigger has changed. im using an integer counter that increases everytime a record is changed, and at the end it is displayed. the only problem is that debug is not displaying.

 

here's my code:

 

/*  This is a bulk Trigger designed to change the status of leads created before
 *  a pre-determined date to a pre-determined status automatically
 *
 * @Author: Greg Coley
 * @Created: July 20th 2010
 */

//Fires on the succesfull update of a lead
trigger oldLeadBulkStatusUpdate on Lead (after insert)
{
    //the status to be put in place of the older leads current status
      String newStatusForOldLeads;
   
   
    //set the new status below in format('Status goes between single quotes like this')
     newStatusForOldLeads = 'Dead';

   
    //the list that will hold the selected list
      List<Lead> oldLeads;

   
    //search for all the leads whose status we havent changed yet, because salesforce limits us to pulling only 1000
    //objects at a time from the db, we mus limit our search results, i limit to 900...just in case.
    oldLeads = [select id, createdDate, status, isConverted from Lead where status !=: newStatusForOldLeads limit 900];
     

   
   
   
    //Do not change this line.
    for (Lead ld: trigger.new)
  {
      //Create the counter, which will be used to tell us how many records we have updated.
      Integer changeCounter;
     
           
      //the predetermined date that qualifies a lead as 'old'
      Date   oldThreshold;
     
     
     
    
     //set the threshold date below in format(YYYY,MM,DD)
     oldThreshold = Date.newInstance(2010, 12, 31);
    
         
     //initialize the counter to zero
      changeCounter = 0;
     
     
      // provided the search returns any results we loop through the results and change the status
      // for the lead to the predetermined status, as long as the leads created date is before
      // the pre determined date.
      if(oldLeads.size() > 0){
      for(Lead currentLead: oldLeads)
      {
     
      if (currentLead.CreatedDate < oldThreshold && currentLead.isConverted == false)
        {
          currentLead.status = newStatusForOldLeads;
          update(currentLead);
          changeCounter++;
        }
       
            }
      }
      //throws feedback to the system log
        system.debug(' ________________________________________________________________ ');
        system.debug('|Updated: '+ changeCounter +' Records out of a possible 900                                        |');
        system.debug('|================================================================ |');
        system.debug('|Note: if the two numbers above are the same you probably have to                               |');
        system.debug('|run again. when the first number is 0, all updates are finished.                                      |');
        system.debug('------------------------------------------------------------------------------------------------------------------');
     
      
  }

 


}

I am 99.9% sure I have set access control correctly. The page displays, but for some reason it will not display/render an <apex:inputField>. Nothing shows up at all. Doesn't throw an error, it just seems to be ignoring any and all <apex:inputField>'s. Any ideas? This is all under a testing dev org. Thank you!

  • July 09, 2010
  • Like
  • 0

I am trying to create a dynamic picklist in a datatable. The issue I'm having is that I need to set the default value of the picklist, and I need to be able to store the value of whatever it is changed to, which will be bound to some variable in a list.

 

To accomplish this I created a new field on the object I'm using (called Vendor), called "selected_vendor__c":

 

 

<apex:column headerValue="Vendor">

     <apex:selectList value="{!i.selected_vendor__c}" size="1" required="true" >
     <apex:selectOption itemValue="" itemLabel=""/>
     <apex:selectOptions value="{!VendorList}"/>
     </apex:selectList> 
                
</apex:column> 

 

All that I'm trying to accomplish is to have the value in the picklist pre-set to whatever the value of "selected_vendor__c" is (which I set dynamically in the list that creates "i"). It doesn't seem to be reflecting this value in the dropdown list.

 

 

Furthermore, I'm hoping that it will also save the value to the List I have in the controller. I've only ever set the value of a picklist to a single variable.

 

Thanks!

  • July 09, 2010
  • Like
  • 0

The subject kind of says it all. I can add an "oncomplete" attribute to the actionfunction that will execute some javascript, but the <apex:repeat> tag I have inside the <apex:facet name="stop"> does not.

 

Can anyone suggest why this might be the case? Is there another way to go about this where I could render some VF code upon completion of an ajax call?

 

Thanks!

  • July 08, 2010
  • Like
  • 0

 

     List<Task> histories = [Select id,Ownerid,whatid,whoid,activitydate,subject,website__c From Task where (whatid=:relatedLink.id and Ownerid=:currentUser and Status='Not Started') limit 1]; 

 

 

 

I'm getting an exception when deploying that is telling me  "Too many query rows: 501".

 

Doesn't the "Limit 1" take care of this??

 

Thanks!

  • July 06, 2010
  • Like
  • 0

In the past I was hitting the govenor limit of 21 quieres and have been able to work through that, but after I retooled my trigger and class, I am getting the same error.

 

I have this trigger:

 

trigger UpdateOppChatterFeed on OpportunityLineItem (after update) 
{
      integer size = Trigger.new.size();

      for(integer i = 0; i < size; i++)
      {
            Chatter_Feed cf = new Chatter_Feed();
            cf.updateChatter(Trigger.new[i]);
      }
}

 

 

which calls this class:

 

 

public with sharing class Chatter_Feed 
{

	public void updateChatter(OpportunityLineItem  oli)
	{
            List<FeedPost> posts = new List<FeedPost>();
            List<Opportunity> oppList = new List<Opportunity>();
            List<Opportunity> OppsToBeUpdated = new List<Opportunity>();
            
            oppList = [select Id
            		   from Opportunity 
            		   where id = : oli.OpportunityId];
            		   
						
            id idToUpdate;   
            for(Opportunity opp : oppList)
            {
                  idToUpdate = opp.Id;			
            }
	    System.debug('MIKES OPP ID IS '  + idToUpdate);
            //update OppsToBeUpdated;
            List<OpportunityFeed> opportunityFeedPosts = [SELECT Id, Type, FeedPost.Body
                                                            From OpportunityFeed
                                                            Where ParentID = :idToUpdate
                                                            ORDER BY CreatedDate DESC];
                                                            
                                                            
            String bodyText = 'This is the body ';                                                
            FeedPost opportunityPost = new Feedpost();
            opportunityPost.Type = 'LinkPost';
            opportunityPost.Title = 'THIS IS THE TITLE WILL';
            opportunityPost.Body = bodyText;
            String id = String.valueOf(oli.id).substring(0,15);
            opportunityPost.LinkURL = 'https://cs1.salesforce.com/'+id;
            opportunityPost.ParentID = idToUpdate;
            posts.add(opportunityPost);
            	
            //}                                        
                                                            
            insert posts;                                              

      }
 
  
}

 

 

The only for() loop that I have is in the class and does not query any sObjects.

 

This trigger/class works when I edit 1 OpportunityLineItem, but our Org has an option to edit all and in some cases, there are more than 21 line items on an Opportunity.

 

Why is this failing?  Can someone please give me some guidance here?

 

 

I would appreciate any feedback

 

Thanks!!

 

~Mike

Hi there, I've written a trigger that sends an email based upon a new opportunity. Trigger works great. Now for the test classes. I've got this test class:

public class testEmailTrigger {
	//This class is simply to test the SendEmailTrigger trigger
	
	//Test Method
	static testMethod void testEmail {
		//Insert a record into the right table to test
		//In this case, the table is Opportunity

		Opportunity o = new Opportunity ();
		o.Amount='100';
		o.CloseDate = System.Today();
		o.Description = 'TEST';
		
		//Start the test
		test.startTest();
		insert o;
		test.stopTest();
	}

}

It complains at the line "Opportunity o = new Opportunity(); with the error "unexpected token Opportunity." What am I doing wrong?

We are building some logic in apex trigger to find out which environment  (sandbox/production) we are in. How to get the value of this.

 

For example: when we are in our sales force sandbox  UI, it shows "Force.com Sandbox: SFDPOC". The string "SFDPOC" is the environment name. How to get this value "SFDPOC" in a trigger?

I'm a noob programmer so, this may seem like a dumb question. 

 

I'm trying to assess how I should build my app and if I should use the Force.com builder or another scripting technology to integrate into Force.com.  I'm building a project management app that will have multiple calculations and resource assignments. 

 

Is there a simple way to assess what the limits of the builder are?  Something like, if you want to build an app with (x) capabilities, then you can use Force.com builder, but if you want to build an app with (y) capabilities, then you should use a different technology.

 

Additional (though perhaps unnecessary) background:  I have resources who are comfortable scripting in PHP, AJAX, C#, and ASP.NET, and I'm trying to assess if I can just use the native Force.com builder or API, or if the app produced will be too cumbersome.  At the end of the day, users will be entering multiple tasks, assigning resources, and running calculations. 

 

Thanks for your help!

Hello.  On p. 420 of the 2008 Force.com Developers Guide (distributed at Dreamforce 2008), it says that "Message.sendMail method takes an array of messages to send, so you can send multiple messages in one single call."

 

Does this mean I can send an array of different email messages, each to a single recipient, in one call?  What is the syntax for constructing the array?  The documentation is not clear.

 

Here are the specifics of my situation: I need to send an email containing a personalized URL to several people, and I can't use merge fields/templates because the people's data are stored in a custom object, not in the Contact object.

 

Thanks

David

Will an "onUpdate" trigger fire on a parent object when a new child record is inserted? Is there anyway to prevent that from happening? I'm getting self-reference problems when I want to insert a new record under some circumstances, but I specifically do not need or want the trigger of the parent object to fire.

 

Thanks!

  • April 02, 2010
  • Like
  • 0

Hi All,

 

I just logged this issue with SF.com support.  However, I figured I'd post the issue to the forum as well, to see which venue yields a better response. :)

 

---

 

I have a single Custom Field ("Handles_Title__c" ) on a Custom Object ("Purchase__c" ) that I would like to deploy via the Force.com IDE. However, I am getting an error "Must specify a non-empty label for the CustomObject" when I try to deploy this field.


Steps for Reproduction:

Preconditions:

I have two sandboxes, "greg" and "stage". Both sandboxes have acustom object called "Purchase__c". However, the Purchase__c object onthe "greg" sandbox has an additional field called "Handles_Title__c"that does not exist in "stage".

Steps:

1) In eclipse, go to File -> New -> Force.com Project. Create a new project pointing to the "greg" sandbox.

2) On the "Choose Initial Project Components" page, choose the"Selected metadata components" radio button, and click the "Choose..."button.

3) On the "Choose Metadata Components" page:
3.a) Expand the "objects - custom list"
3.b) Expand the "Purchase__c" list
3.c) Expand the "customfield" list
3.d) Check the box next to "Handles_Title__c"
3.e) Click the "Ok" button

4) Back on the "Choose Initial Project Contents" page, click the "Finish" button.

5) Right click the "src" folder in the newly created project. Select Force.com -> Deploy to server...

6) Enter login credentials for the "stage" sandbox, click "Next".

7) On the "Archive Options" screen, uncheck both "archive" checkboxes, click "Next".

8) On the "Deployment Plan" screen, check the "Overwrite" box for "Purchase__c". Click the "Next" button.  


Expected Results:

The custom field "Handles_Title__c" should be created in the stage sandbox.


Actual Results:

Deployment fails with the error: "Must specify a non-empty label for the CustomObject" 

 

 

Message Edited by glorge on 12-08-2009 04:13 PM
  • December 09, 2009
  • Like
  • 0