• Kevin Rusk
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Need a consultant to handle conversion of clients from a small Redtail database to our existing Salesforce.  We are using the TDA WealthManagement app as our underlying framework.  If you have experience doing this conversion, please contact me.
We have a situation that a field has been mistakenly overwritten.  Unfortunately, the field is not included in the History Tracking on the Object.

I am just trying to see if there is anything where I could possibly get the prior value of this field.  Any suggestions would be helpful.
I have created a trigger on the Opportunity Object.  When I test it under the GUI, the field gets populated properly.  Now I need to get the Test Class to run the trigger so that I can move it to Prod.

Here is the trigger:

trigger Referral_Name_autofill on Opportunity (before insert) {

    For (Opportunity n : Trigger.new)    { 
    
        IF (n.referrer_SFID__c != Null) {
        
            String found = '';        
            System.Debug('New SFID In; ' + n.referrer_SFID__c);
            System.Debug('New AccountID In; ' + n.AccountID);
            Contact[] HofH = [SELECT Id, Relationship__c, Name FROM Contact WHERE AccountID = :n.referrer_SFID__c];
        
            FOR(Contact h:HofH){
            
                IF (h.Relationship__c == 'Head of HH') {
                    
                    IF (found == '')    {
                        n.Referral_Name__c = h.Id;
                        found = 'FOUND';
                    }
                
                }
            
            }
            
            IF (found == '')    {
            
                Contact[] contacts = [SELECT Id, TDAI_WM__Relationship__c, Name FROM Contact 
                                        WHERE AccountID = :n.referrer_SFID__c
                                        ORDER BY CreatedDate DESC];
                                        
                FOR(Contact c:contacts){
                    
                    n.Referral_Name__c = c.Id;
                       BREAK;
                
                }
            
            }            
        
        }
    
    }

}

Here is the test class:

@isTest
private class Referral_Name_autofill_Testclass {
static testMethod void myUnitTest() {
System.debug('Here');
  Opportunity op1 = New Opportunity( AccountId='001e000000SobCeAAJ', Name='TestOpp', referrer_SFID__c='001e000000SobCe',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op1;
        System.debug('Referral Name after trigger fired: ' + op1.Referral_Name__c);
    
    Opportunity op2 = New Opportunity( AccountId='001e000000SZhdgAAD', Name='TestOpp', referrer_SFID__c='001e000000SZhdg',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op2;
        System.debug('Referral Name after trigger fired: ' + op2.Referral_Name__c);
    
       
    FOR(Contact n:[SELECT Id, AccountId FROM Contact LIMIT 1]){
        System.debug('Here we go');
        Opportunity op = New Opportunity( AccountId=n.AccountId, Name='TestOpp', referrer_SFID__c=n.Id,
                                   StageName='Prospect Received', CloseDate=Date.today() );
        // Insert Opportunity
        insert op;
        
        // Retrive Referal Name
        op = [SELECT Referral_Name__c FROM Opportunity WHERE Id =:op.Id];
        System.debug('Referral Name after trigger fired: ' + op.Referral_Name__c);
    }
}
}

According to the Test Execution Log, none of the SOQL Queries pull any rows.  When I run them individually in DC, I get the correct record I need.  I know it is something that I am not seeing.

I am working on creating an Apex Trigger to copy the SSN from Contact to a Custom Object.  The Custom Object has the ID of the Contact Record.  It is not copying the data.  I only want this if the SSN field on the Custom Object is blank and only when a new Custom Object Record is created.  I have tried a couple of different ways based on some searches for how to write a trigger.

Here is my current Trigger:

 trigger Set_SSN_Registration on Registration__c (before insert)

{

Set<Id> IndId = new Set<Id>();


for (Registration__c reg : Trigger.new)
       
 IndId.add(reg.Individual__c);
       


//Contact ssn = [

//    SELECT SSN_Tax_ID__c from Contact

//    WHERE ID = :IndId

//    ];

 

Map<Id, Contact> entries = new Map<Id, Contact>(
       
 [select SSN_Tax_ID__c from Contact
        
 where id in :IndId]);
         

 

for (Registration__c reg :trigger.new){
    

 if(reg.SSN_Tax_ID__c == null){

   
  reg.SSN_Tax_ID__c = entries.get(reg.Individual__c).SSN_Tax_ID__c; 
 
}
}
}

Need a consultant to handle conversion of clients from a small Redtail database to our existing Salesforce.  We are using the TDA WealthManagement app as our underlying framework.  If you have experience doing this conversion, please contact me.
I have created a trigger on the Opportunity Object.  When I test it under the GUI, the field gets populated properly.  Now I need to get the Test Class to run the trigger so that I can move it to Prod.

Here is the trigger:

trigger Referral_Name_autofill on Opportunity (before insert) {

    For (Opportunity n : Trigger.new)    { 
    
        IF (n.referrer_SFID__c != Null) {
        
            String found = '';        
            System.Debug('New SFID In; ' + n.referrer_SFID__c);
            System.Debug('New AccountID In; ' + n.AccountID);
            Contact[] HofH = [SELECT Id, Relationship__c, Name FROM Contact WHERE AccountID = :n.referrer_SFID__c];
        
            FOR(Contact h:HofH){
            
                IF (h.Relationship__c == 'Head of HH') {
                    
                    IF (found == '')    {
                        n.Referral_Name__c = h.Id;
                        found = 'FOUND';
                    }
                
                }
            
            }
            
            IF (found == '')    {
            
                Contact[] contacts = [SELECT Id, TDAI_WM__Relationship__c, Name FROM Contact 
                                        WHERE AccountID = :n.referrer_SFID__c
                                        ORDER BY CreatedDate DESC];
                                        
                FOR(Contact c:contacts){
                    
                    n.Referral_Name__c = c.Id;
                       BREAK;
                
                }
            
            }            
        
        }
    
    }

}

Here is the test class:

@isTest
private class Referral_Name_autofill_Testclass {
static testMethod void myUnitTest() {
System.debug('Here');
  Opportunity op1 = New Opportunity( AccountId='001e000000SobCeAAJ', Name='TestOpp', referrer_SFID__c='001e000000SobCe',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op1;
        System.debug('Referral Name after trigger fired: ' + op1.Referral_Name__c);
    
    Opportunity op2 = New Opportunity( AccountId='001e000000SZhdgAAD', Name='TestOpp', referrer_SFID__c='001e000000SZhdg',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op2;
        System.debug('Referral Name after trigger fired: ' + op2.Referral_Name__c);
    
       
    FOR(Contact n:[SELECT Id, AccountId FROM Contact LIMIT 1]){
        System.debug('Here we go');
        Opportunity op = New Opportunity( AccountId=n.AccountId, Name='TestOpp', referrer_SFID__c=n.Id,
                                   StageName='Prospect Received', CloseDate=Date.today() );
        // Insert Opportunity
        insert op;
        
        // Retrive Referal Name
        op = [SELECT Referral_Name__c FROM Opportunity WHERE Id =:op.Id];
        System.debug('Referral Name after trigger fired: ' + op.Referral_Name__c);
    }
}
}

According to the Test Execution Log, none of the SOQL Queries pull any rows.  When I run them individually in DC, I get the correct record I need.  I know it is something that I am not seeing.

I am working on creating an Apex Trigger to copy the SSN from Contact to a Custom Object.  The Custom Object has the ID of the Contact Record.  It is not copying the data.  I only want this if the SSN field on the Custom Object is blank and only when a new Custom Object Record is created.  I have tried a couple of different ways based on some searches for how to write a trigger.

Here is my current Trigger:

 trigger Set_SSN_Registration on Registration__c (before insert)

{

Set<Id> IndId = new Set<Id>();


for (Registration__c reg : Trigger.new)
       
 IndId.add(reg.Individual__c);
       


//Contact ssn = [

//    SELECT SSN_Tax_ID__c from Contact

//    WHERE ID = :IndId

//    ];

 

Map<Id, Contact> entries = new Map<Id, Contact>(
       
 [select SSN_Tax_ID__c from Contact
        
 where id in :IndId]);
         

 

for (Registration__c reg :trigger.new){
    

 if(reg.SSN_Tax_ID__c == null){

   
  reg.SSN_Tax_ID__c = entries.get(reg.Individual__c).SSN_Tax_ID__c; 
 
}
}
}