• Quanchi
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 13
    Replies

Hello,

 

If you can help point me in the right direction, it would be a great help.

 

I need an Apex Trigger that updates opportunity #1 custom field #1 with the opportunity ID from Opportunity #2 when Opportunity #2 custom field #2 (lookup field for opportunity name) is populated with opportunity #1's ID.  Hope this makes sense.

 

Thanks,

Quanchi

Hello,

 

I have followed the directions perfectly from the below link and everything works fine.....emails send.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_custom_controller.htm

 

 

I need to add a browse button to allow the user to add local files as attachments to the email.  The email is not saved in Salesforce, it is just sent to the recipient.

 

I am having problems with the email.setFileAttachments portion of the class.

 

Any ideas?

 

Thanks,

Qaunchi

 

 

 

Hello,

 

I have and Apex trigger that works fine but I need to make a change to it.......and I can't figure out how to do it.

The code works great when creating a new record.....I also need it to execute when an update it made.

 

The code gets the user's managers name and populates a field in the opportunity object.  I need it to update this field when the opportunity owner changes.  Any help would be most appreiciated.

 

Thanks.

 

******************************************************************************************

 

 

 

trigger Opp_Owner on Opportunity (before insert, before update ) {
/*****************************************************************************
Name     : Update Owner Manager on the opportunity from the User object

Purpose  : defaults the Owner Manager field of the opportunity from the User

******************************************************************************/
    
  //holds User Ids
  Set<Id> setUserIds = new Set<Id>();
 
  //holds a list of Users
  List<User> lstUser = new List<User>();
 
  //holds key value pairs of User Id and User Object
  Map<Id, User> mapUserObj = new Map<Id, User>();

  //holds User object
  User UserObj;
  
  //For each opportunity being inserted add User Id value in in Set of User Ids.
  for(Opportunity oppObj : Trigger.new){
    if(oppObj.OwnerId != null){
      setUserIds.add(oppObj.OwnerId);
    }
  }
 
  
  //Fetch all Users whose Id is in the Set.
  lstUser = [select Id, Name, Manager_Full_Name__c, ManagerId from User where Id in :setUserIds Limit 1000];
  if(lstUser.size() == 0){
    return; 
  }
 
  //Add these fetched Users in a Map <User Id, User object>
  for(User usrObj : lstUser){
    mapUserObj.put(usrObj.Id, usrObj); 
  }
 
  //for each opportunity being inserted get User from the map and update the field values
  for(Opportunity oppObj : Trigger.new){
    //get User object
    if(oppObj.OwnerId != null){
      if(mapUserObj.containsKey(oppObj.OwnerId)){
        UserObj = mapUserObj.get(oppObj.OwnerId);
        //map opportunity fields to User fields
        oppObj.Opportunity_Owner_s_Manager__c = UserObj.Manager_Full_Name__c;
      } 
    }
  }

 }

 

 

Hello,

 

I need help with an Apex trigger.  I have one custom object connected to the Account object.  The custom object keeps track of active items.  I need an Apex trigger that populates a field on the main Account object based on what is in the child object.   See below.

 

Account Object

 Custom Fields Text Value 
 

Favorite Ice Cream:

Vanilla

 
 

Favorite Color:

Green

 
 

Favorite Fruit:

Apple

 
    
    

Child Object

Item Name

Active

Type

 

Vanilla

Yes

Ice Cream

 

Chocolate

No

Ice Cream

 

Apple

Yes

Fruit

 

Orange

No

Fruit

 

Green

Yes

Color

 

Purple

No

Color

 

Yellow

No

Color

 

Red

No

Color

 

So, in this example….since type = Color and Active = Yes, then the text value of “Green” is populated in the Favorite Color field on the Account object.  Hope this makes sense.

 

Thanks for any help.

Hello,   We just rolled out Salesforce, so my team is learning the system.

 

We have a custom object that lists multiple records connected to the Account object.  I need a trigger that updates a specific field on the Account object when certain criteria is met for a record on the child object.

 

So.....example

 

Object:   Account

Custom field:  Favorite ice cream

 

Child object:  List of favorite foods

custom fields: type of food, flavor, active

 

If type of food = ice cream and active = TRUE, then account.favorite_ice_cream = flavor

 

Hope I explained this right.......Any help would be appreciated.

 

Thanks in advance.

Hello,

 

If you can help point me in the right direction, it would be a great help.

 

I need an Apex Trigger that updates opportunity #1 custom field #1 with the opportunity ID from Opportunity #2 when Opportunity #2 custom field #2 (lookup field for opportunity name) is populated with opportunity #1's ID.  Hope this makes sense.

 

Thanks,

Quanchi

Hello,

 

I have followed the directions perfectly from the below link and everything works fine.....emails send.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_custom_controller.htm

 

 

I need to add a browse button to allow the user to add local files as attachments to the email.  The email is not saved in Salesforce, it is just sent to the recipient.

 

I am having problems with the email.setFileAttachments portion of the class.

 

Any ideas?

 

Thanks,

Qaunchi

 

 

 

Hello,

 

I have and Apex trigger that works fine but I need to make a change to it.......and I can't figure out how to do it.

The code works great when creating a new record.....I also need it to execute when an update it made.

 

The code gets the user's managers name and populates a field in the opportunity object.  I need it to update this field when the opportunity owner changes.  Any help would be most appreiciated.

 

Thanks.

 

******************************************************************************************

 

 

 

trigger Opp_Owner on Opportunity (before insert, before update ) {
/*****************************************************************************
Name     : Update Owner Manager on the opportunity from the User object

Purpose  : defaults the Owner Manager field of the opportunity from the User

******************************************************************************/
    
  //holds User Ids
  Set<Id> setUserIds = new Set<Id>();
 
  //holds a list of Users
  List<User> lstUser = new List<User>();
 
  //holds key value pairs of User Id and User Object
  Map<Id, User> mapUserObj = new Map<Id, User>();

  //holds User object
  User UserObj;
  
  //For each opportunity being inserted add User Id value in in Set of User Ids.
  for(Opportunity oppObj : Trigger.new){
    if(oppObj.OwnerId != null){
      setUserIds.add(oppObj.OwnerId);
    }
  }
 
  
  //Fetch all Users whose Id is in the Set.
  lstUser = [select Id, Name, Manager_Full_Name__c, ManagerId from User where Id in :setUserIds Limit 1000];
  if(lstUser.size() == 0){
    return; 
  }
 
  //Add these fetched Users in a Map <User Id, User object>
  for(User usrObj : lstUser){
    mapUserObj.put(usrObj.Id, usrObj); 
  }
 
  //for each opportunity being inserted get User from the map and update the field values
  for(Opportunity oppObj : Trigger.new){
    //get User object
    if(oppObj.OwnerId != null){
      if(mapUserObj.containsKey(oppObj.OwnerId)){
        UserObj = mapUserObj.get(oppObj.OwnerId);
        //map opportunity fields to User fields
        oppObj.Opportunity_Owner_s_Manager__c = UserObj.Manager_Full_Name__c;
      } 
    }
  }

 }

 

 

Hello,

 

I need help with an Apex trigger.  I have one custom object connected to the Account object.  The custom object keeps track of active items.  I need an Apex trigger that populates a field on the main Account object based on what is in the child object.   See below.

 

Account Object

 Custom Fields Text Value 
 

Favorite Ice Cream:

Vanilla

 
 

Favorite Color:

Green

 
 

Favorite Fruit:

Apple

 
    
    

Child Object

Item Name

Active

Type

 

Vanilla

Yes

Ice Cream

 

Chocolate

No

Ice Cream

 

Apple

Yes

Fruit

 

Orange

No

Fruit

 

Green

Yes

Color

 

Purple

No

Color

 

Yellow

No

Color

 

Red

No

Color

 

So, in this example….since type = Color and Active = Yes, then the text value of “Green” is populated in the Favorite Color field on the Account object.  Hope this makes sense.

 

Thanks for any help.

Hello,   We just rolled out Salesforce, so my team is learning the system.

 

We have a custom object that lists multiple records connected to the Account object.  I need a trigger that updates a specific field on the Account object when certain criteria is met for a record on the child object.

 

So.....example

 

Object:   Account

Custom field:  Favorite ice cream

 

Child object:  List of favorite foods

custom fields: type of food, flavor, active

 

If type of food = ice cream and active = TRUE, then account.favorite_ice_cream = flavor

 

Hope I explained this right.......Any help would be appreciated.

 

Thanks in advance.