• Wingsrul91
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 15
    Replies

I am trying to figure out how to make a new comment required when the record owner is changed.  I assume it is an 'after update' trigger.  I do not see how to integrate the existing comment related list. 

 

Should I create a new comment page via visualforce and redirect the user after they change the owner of the record?

 

Any thoughts

I am trying to populate one field (number) value found on a custom object to another field on the case object.

The scenario goes like this:

After closing a case, the user is sent a customer survey.  The customer survey is a custom object.  After the user is done filling out the survey they submit it.  On the customer survey record is a field which totals the values chosen in the survey.  For example, if the user selects all 5s, the value of this custom formula field on the customer survey record is 25.  This rollup value field is the field I want populated back to the original case from which the survey was sent. 

How do I update the value of the rollup field on the survey object to a field on the case object.  These values should always be the same.

Thank you in advance for your help.
I have created a custom object that is related to the "Cases" object named "case comparison"
 
when you select new case comparison, i set up a formula that pulls the case number.
 
I would like to do the same for a picklist on the case page.  I am receving an error when trying to apply the formula that asks me to use the ISPICKVAL function.  I do not want to specify a specific value, I want it to be a wildcard that automatically makes the new field the same as the picklist value that the user selected. 
 
The picklist i want copied over is the "Type" field on the case page.  This type field should be the same value on the case comparison field.
 
Thank you for any help you can provide.
Hi All!
 
I am trying to auto create a record in a custom object when a new "Case" record is manually created.
 
I assume I use a trigger to set this up but dont even know where to begin.  Can someone please point me in the right direction.
 
In addition, I would like a field in the custom object to be automatically populated with information from the new "case" record.
 
Thank you in advance for any information you can provide.
Hi guys,

This is the first trigger i am trying. I wanted to create a workflow or something by which i could populate a custom field in Account with some profile info from a field from the User Info page. It seems there is no way to get the user info for the person who created the record using workflow and triggers are the only choice.

So i have been reading up on it and trying to come up with a solution. I will post my attempts here, hopefully you guys can help me so that i can archive my goal and also learn about triggers.

trigger updateProfile on Account (after update)
{
      Account.Profile__c = User.Division;
}

Here i am trying to get the Division name for the user and input it into the custom field called Profile in the Account object. This is not working for me, can someone tell me what i am doing wrong?

Thanks!
Hi All,

    Good day. Is there a way to set the record type of a record to be saved via VF? Thanks!
Hi Everyone,
                     I have a requirement where i need to check the Owner Territory, and User Title Before Update,
The Previous owner can transfer the particualr opportuntiy to a new Owner if the Parent Territory of both (New Owner, Previous Owner) are same and the new user has title as "Special" .  A particular user can sit on  more then one territory. so only those users can be new owner which satisfy this condition.

I am new to Apex, i wrote something based on S-Control i saw on the community.
 
Code:
trigger NewOwner on Opportunity (before update, after update) 
{
//string profileid =UserInfo.getProfileId();
ID oppsid = Trigger.old[0].Id;
User[] PreviousOwner = [select id, profileid from User where id=:Trigger.old[0].OwnerId Limit 1];
//String OwnerId = user.Id[0];
if(PreviousOwner[0].ProfileId =='00eT0000000dnyE')
{
// Territory of the Owner
UserTerritory[] OwnerTerritory = [select Id, TerritoryId, IsActive from UserTerritory where UserId=:Trigger.old[0].OwnerId and IsActive = TRUE];
for(Integer i=0; i<OwnerTerritory.size(); i++)
{
// Parent Territory of the Owner
Territory[] OwnerParentTerritory = [select Id, Name, ParentTerritoryID from Territory where Id=:OwnerTerritory[i].TerritoryId];
for (Integer j=0; j<OwnerParentTerritory.size(); j++)
{
// Get the New User's Id and Title.
User[] NewOwner = [select Id, Title from User where id=:Trigger.new[0].OwnerId Limit 1];
// To get the New User's Territory
UserTerritory[] NewOwnerTerritory = [select Id, TerritoryId, IsActive from UserTerritory where UserId =:Trigger.new[0].OwnerId and IsActive = TRUE];
Territory[] NewOwnerParentTerritory = [select Id, Name, ParentTerritoryID from Territory where Id=:NewOwnerTerritory[0].TerritoryId];
for(Integer k=0; k<NewOwnerParentTerritory.size(); k++)
if(NewOwner[0].Title == 'Special' && NewOwnerParentTerritory[k].ParentTerritoryID == OwnerParentTerritory[j].ParentTerritoryID)
{
UserTerritory[] OldOwner = [select TerritoryId, UserId from UserTerritory where UserId=:Trigger.old[0].OwnerId and IsActive = TRUE];
for(Integer l=0; l<OldOwner.size(); l++)
{
for(UserTerritory OldOwnerTerritoryUsers:[select UserId from UserTerritory where TerritoryId=:OldOwner[l].TerritoryId and IsActive = TRUE])
{
OpportunityShare oppsshare = new OpportunityShare();
oppsshare.OpportunityId = oppsid ;
oppsshare.UserOrGroupId = OldOwnerTerritoryUsers.UserId;
oppsshare.OpportunityAccessLevel = 'Read';
try
{
insert oppsshare ;
}
catch (Exception e)
{
System.debug(e.getMessage());
}
}
}
}
/*else
{
Trigger.new[0].OwnerId.addError('Deal can only be assigned to User in your parent territory and with title as Special');
}
*/
}
}
}
}
}

The trigger saved and also is valid but at the time of Operation, i recieve this error message.
Error - Apex trigger: NewOwner caused an unexpected exception, contact your administrator: NewOwner: execution of BeforeUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.NewOwner

Error: Apex trigger NewOwner caused an unexpected exception, contact your administrator: NewOwner: execution of AfterUpdate caused by: System.Exception: Too many SOQL queries: 21: Trigger.NewOwner: line 18, column 19

If someone can please help me with this, would be great help.
Many Thanks in Advance.
Developer118


Message Edited by Developer118 on 02-12-2008 02:16 PM

Message Edited by Developer118 on 02-12-2008 02:17 PM
Hi
 
Any of clever people know how to create a formula field that will look up the Owners Telephone number from the user record.
 
The $User Merge fields, only put the current users phone number not the owner, is there any way to create a formula to do this?
 
The reason for this is we use Exact Target Email tool, and they ahve recently upgraded and now you can only include contact or Lead fields on your email templates.   It would be nice to have the owners phone number on the emails. 
 
Of course I could create and populate a standard custom field, but would prefer it to recalculate when owner changes.
 
Appreciate any suggestions.
 
Regards