• Dave Scott
  • NEWBIE
  • 34 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 11
    Replies
Hi all, hope you can help!

Please could someone help me create a custom button the Contact object that will send a template email to that particular contact and record the email in Activity History.

Our company has two brands and therefore two different templates, so we need to make sure the correct branded template is sent out to the contact.  The brand is determined by a custom picklist field on the Contact object called 'Brand__c' and has only two values 'Brand X' and 'Brand Y'.

How can this be done?

Many thanks,
Dave
Hi folks I wondered if you could help.

I have a custom object named 'RM Database' with two custom fields named 'RM Email Address' and 'Portfolio Code' (the unique record identifier).

On the 'Lead' and 'Account' objects I have a custom Lookup Relationship field called 'RM Portfolio Code' and an email field called 'RM Email address'.  I want the 'RM Email address' field to reference the selected 'RM Portfolio Code' field and this is where I'm struggling.

So far I've tried to edit the formula for the default value on the email field to reference the custom object however it won't let me do that.  I've also tried to create a Workflow rule to update the field which works but not in the desired way, I want it to happen automatically.

Please can someone help me write a trigger (and a test class) that will help with this?

Many thanks,
Dave
Hi folks,

I have a trigger that updates a custom field on the Opportunity called 'Primary Contact' with the name of the Primary Contact on the related Opportunity when the Stage is changed to either '8-Deal Lost' or '9-Deal Withdrawn'.

Please can you help me make changes to this trigger that would carry out this update whenever the Opportunity record is updated rather than when the Stage Name is chanaged?
 
trigger trgr_Opportunity_FetchPrimaryContactEmail on Opportunity 
(
    after Insert, 
    after Update
) {

    Set setOpportunity = new Set();
    for(Opportunity oppty : trigger.new){
        if(
            oppty.StageName == '8-Deal Lost' ||
            oppty.StageName == '9-Deal Withdrawn'
        ){
            setOpportunity.add(oppty.Id);
        }
    }

    if(!setOpportunity.isEmpty()){
        Map opptyToOpportunityContactRoleMap = 
            new Map();

        for(
            OpportunityContactRole conRole:
            [
                SELECT  Id, OpportunityId, ContactId
                FROM    OpportunityContactRole
                WHERE   
                        OpportunityId IN :setOpportunity AND
                        IsPrimary = TRUE
            ]
        ){
            opptyToOpportunityContactRoleMap.put(
                conRole.OpportunityId,
                conRole
            );
        }

        List lstOpportunityToUpdate = 
            new List();
        if(!opptyToOpportunityContactRoleMap.isEmpty()){
            for(Opportunity oppty : trigger.new){
                if(
                    opptyToOpportunityContactRoleMap.containsKey(oppty.Id) &&
                    oppty.Primary_Contact__c != 
                        opptyToOpportunityContactRoleMap
                            .get(oppty.Id)
                            .ContactId
                ){
                    lstOpportunityToUpdate.add(
                        new Opportunity(
                            Id = oppty.Id,
                            Primary_Contact__c = 
                                opptyToOpportunityContactRoleMap
                                    .get(oppty.Id)
                                    .ContactId
                        )
                    );
                }
            }

            if(!lstOpportunityToUpdate.isEmpty()){
                UPDATE lstOpportunityToUpdate;
            }
        }
    }
}

Hope that's ok, many thanks in advance for all your help.

Many thanks,
Dave
Hi folks, hope you can help.

I'm trying to edit a trigger on the case object that forms part of the Round Robin Record Assignment app from the Appexchange however I'm having issues with it and could do with some help.

In the comments listed here: https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000178fsEAA&revId=a0S30000000fPTLEA2&tab=r (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000178fsEAA&revId=a0S30000000fPTLEA2&tab=r) it provides instructions on how to edit the trigger to prevent having to change the record owner twice when having to manually reassign a record to another user.

When editing the trigger in Sandbox I get the following error and I don't know why:
Error: Compile Error: line 87:44 no viable alternative at character '”' at line 87 column 44
Please can you help me understand what I'm doing wrong.

The only thing I'm changing in the trigger is:
Trigger.new[i].TempOwnerId__c = ag.User__c;
and changing it to:
Trigger.new[i].TempOwnerId__c = ”;

Really hope you can help folks, thanks for your help in advance.

Many thanks,
Dave
Hi folks, hope you can help.

I recently company policy change means that we're not allowed to have any 8 digit account numbers stored on cases received via Email-to-Case.

Is there any way to get Salesforce to alert the Salesforce admin of any instances or even possibly remove the 8 digit account numbers from the case entirely or blank out the first 5 digits perhaps?

Any help on this would be greatly appreciated.

Many thanks,
Dave

Hi all, really hope someone can help with this issue.

 

We have a situation where a user will type in a whole heap of comments for a particular lead, however when the lead is converted to an opportunity, these comments are then lost and don't carry over.

 

Is there anyway I can fix it so that the comments that are input for a lead are carried over when converting a lead?

 

I am very new to Salesforce so the simplist explanation would be much appreciated!

 

Many thanks,

Dave

Hi all, hope you can help!

Please could someone help me create a custom button the Contact object that will send a template email to that particular contact and record the email in Activity History.

Our company has two brands and therefore two different templates, so we need to make sure the correct branded template is sent out to the contact.  The brand is determined by a custom picklist field on the Contact object called 'Brand__c' and has only two values 'Brand X' and 'Brand Y'.

How can this be done?

Many thanks,
Dave
Dear All,

I'm not able to acheieve 75% code coverage for the following APEX Class :

=====================================================================
public class cvrDispController {
    
     //property
     public Customer_Visit_Report__c cvr {get; set;}
     public ListlstInvitee
     {   get;set;    }
     public ListlstAgenda  
     {   get;set;    }
     public ListlstActionPoint  
     {   get;set;    }
      
    
      // Constructor
      public cvrDispController(ApexPages.StandardSetController stdSetController){
          //stdSetController.setPageSize(10);
          cvr = new Customer_Visit_Report__c();
          lstInvitee = new List();
          lstAgenda = new List();
          lstActionPoint = new List();
            
          if(apexPages.currentPage().getParameters().containsKey('id') )
          {
            try {
                 Id cvrId = apexPages.currentPage().getParameters().get('id');
                 cvr = [select Name, Id, Date_of_Visit__c, Start_Time__c, End_Time__c, Discussion_Reference__c, Venue__c,Type__c,Account__c from Customer_Visit_Report__c where Id =:cvrId limit 1 ];
                 lstInvitee = [select Customer_Visit_Report__c, Invitee_Name__c, Id,Organization__c  from Invitee__c where Customer_Visit_Report__c =:cvrId ];
                 lstAgenda = [select Customer_Visit_Report__c, Id,Discussion_Topics__c from Agenda__c where Customer_Visit_Report__c =:cvrId ];
                 lstActionPoint = [select Customer_Visit_Report__c, Id,Action_By__c,Action_To_Be_Taken__c,BU__c,Completion_Date__c,Discusssion_Point__c,Status__c from Action_Point__c where Customer_Visit_Report__c =:cvrId  ];
            }catch (exception e) { }
          }    
      }
       
    Public Customer_Visit_Report__c getCVR(){
        
          return cvr;
    }
    
    Public List getInvitees(){
        
          return lstInvitee;
        
    }
    
    Public List getAgenda(){
        
          return lstAgenda;
       
    }
    
    Public List getActionPoint(){
        
          return lstActionPoint;
        
    }
      
}
==================================================================
Following is the correpinding Test Class :
@isTest
public class testcvrDispController {
    
    public static testMethod void testcvrController() {
        ApexPages.StandardSetController stdSetController;       
        cvrDispController controller = new cvrDispController(stdSetController);
        
         Account acc = new Account(Name='CG-UK',CurrencyIsoCode='GBP');
        insert acc;
         
        System.assertEquals(acc.Name,'CG-UK');
        System.assertEquals(acc.CurrencyIsoCode,'GBP');
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
        User usr = new User(Alias = 'dmray', Email='dm.ray@mjunction.in',
            EmailEncodingKey='UTF-8', LastName='Ray', LanguageLocaleKey='en_US',
            LocaleSidKey='en_US', ProfileId = p.Id,
            TimeZoneSidKey='America/Los_Angeles', UserName='dm.ray@mjunction.in');
         
         insert usr;
         
         controller.cvr = new Customer_Visit_Report__c(Name='TestCVR2016-6',Account__c =acc.id ,Date_of_Visit__c=date.today(),Discussion_Reference__c='Test DR3',
                                                                  End_Time__c=date.today()+2 ,Start_Time__c=date.today()+1 ,Type__c='Existing Business',Venue__c='KOL' );
                    
        insert controller.cvr;
        
        controller.lstInvitee.add(new Invitee__c(Customer_Visit_Report__c=controller.cvr.id,Invitee_Name__c='VV',Organization__c='MJ'));
        
        insert controller.lstInvitee;
        
        controller.lstAgenda.add(new Agenda__c(Customer_Visit_Report__c=controller.cvr.id,Discussion_Topics__c='Test AGD-3'));
        
        insert controller.lstAgenda;
        
        controller.lstActionPoint.add(new Action_Point__c(Action_By__c=usr.id,Action_To_Be_Taken__c='Test-3',BU__c='MJ',Completion_Date__c=date.today()+4,
                                                          Customer_Visit_Report__c=controller.cvr.id,Discusssion_Point__c='Test DP-3',Status__c='Started'));
        
        insert controller.lstActionPoint;                    
                    
          
            if(apexPages.currentPage().getParameters().containsKey('id') ){
             
                System.debug('Info: controller.cvr.id'+ controller.cvr.Id);
                System.debug('Info: controller.lstInvitee'+ controller.lstInvitee);
                System.debug('Info: controller.lstAgenda '+ controller.lstAgenda );
                
            }
        
        Customer_Visit_Report__c cvr = controller.getCVR();
        List lstInvitee = controller.getInvitees();
        List lstAgenda = controller.getAgenda();
        List lstActionPoint = controller.getActionPoint();
        
        
        cvr.Venue__c = 'KAN';
        cvr.Id = controller.cvr.Id;
        
        upsert cvr;
        
        for(Integer j = 0;j        {
            lstInvitee[j].Invitee_Name__c = 'JJ';            
        }
        
        upsert lstInvitee;        
        
        
        for(Integer j = 0;j        {
            lstAgenda[j].Discussion_Topics__c = 'DP-1';            
        }
        
        upsert lstAgenda;          
        
        
        for(Integer j = 0;j        {
            lstActionPoint[j].Action_To_Be_Taken__c = 'FA Scrap';            
        }
        
        upsert lstActionPoint;  
                     
        
                  
        
    }


}
===========================================================================

I'll be grateful , if you could please help meachieve the minimum 75% code coverage for this APEX  Class.
An early response on this will be appreciated.

Thanks.

Regards,

Debendra Ray
Hi folks,

I have a trigger that updates a custom field on the Opportunity called 'Primary Contact' with the name of the Primary Contact on the related Opportunity when the Stage is changed to either '8-Deal Lost' or '9-Deal Withdrawn'.

Please can you help me make changes to this trigger that would carry out this update whenever the Opportunity record is updated rather than when the Stage Name is chanaged?
 
trigger trgr_Opportunity_FetchPrimaryContactEmail on Opportunity 
(
    after Insert, 
    after Update
) {

    Set setOpportunity = new Set();
    for(Opportunity oppty : trigger.new){
        if(
            oppty.StageName == '8-Deal Lost' ||
            oppty.StageName == '9-Deal Withdrawn'
        ){
            setOpportunity.add(oppty.Id);
        }
    }

    if(!setOpportunity.isEmpty()){
        Map opptyToOpportunityContactRoleMap = 
            new Map();

        for(
            OpportunityContactRole conRole:
            [
                SELECT  Id, OpportunityId, ContactId
                FROM    OpportunityContactRole
                WHERE   
                        OpportunityId IN :setOpportunity AND
                        IsPrimary = TRUE
            ]
        ){
            opptyToOpportunityContactRoleMap.put(
                conRole.OpportunityId,
                conRole
            );
        }

        List lstOpportunityToUpdate = 
            new List();
        if(!opptyToOpportunityContactRoleMap.isEmpty()){
            for(Opportunity oppty : trigger.new){
                if(
                    opptyToOpportunityContactRoleMap.containsKey(oppty.Id) &&
                    oppty.Primary_Contact__c != 
                        opptyToOpportunityContactRoleMap
                            .get(oppty.Id)
                            .ContactId
                ){
                    lstOpportunityToUpdate.add(
                        new Opportunity(
                            Id = oppty.Id,
                            Primary_Contact__c = 
                                opptyToOpportunityContactRoleMap
                                    .get(oppty.Id)
                                    .ContactId
                        )
                    );
                }
            }

            if(!lstOpportunityToUpdate.isEmpty()){
                UPDATE lstOpportunityToUpdate;
            }
        }
    }
}

Hope that's ok, many thanks in advance for all your help.

Many thanks,
Dave
Hi folks, hope you can help.

I'm trying to edit a trigger on the case object that forms part of the Round Robin Record Assignment app from the Appexchange however I'm having issues with it and could do with some help.

In the comments listed here: https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000178fsEAA&revId=a0S30000000fPTLEA2&tab=r (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000178fsEAA&revId=a0S30000000fPTLEA2&tab=r) it provides instructions on how to edit the trigger to prevent having to change the record owner twice when having to manually reassign a record to another user.

When editing the trigger in Sandbox I get the following error and I don't know why:
Error: Compile Error: line 87:44 no viable alternative at character '”' at line 87 column 44
Please can you help me understand what I'm doing wrong.

The only thing I'm changing in the trigger is:
Trigger.new[i].TempOwnerId__c = ag.User__c;
and changing it to:
Trigger.new[i].TempOwnerId__c = ”;

Really hope you can help folks, thanks for your help in advance.

Many thanks,
Dave
Hi folks, hope you can help.

I recently company policy change means that we're not allowed to have any 8 digit account numbers stored on cases received via Email-to-Case.

Is there any way to get Salesforce to alert the Salesforce admin of any instances or even possibly remove the 8 digit account numbers from the case entirely or blank out the first 5 digits perhaps?

Any help on this would be greatly appreciated.

Many thanks,
Dave