• SantoshChitalkar
  • NEWBIE
  • 400 Points
  • Member since 2014
  • Senior Salesforce Developer
  • eClerx


  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 62
    Replies
Hello Devs,

I was going through the blogs and salesforce documentation and few blogger's mentioned to avoid using (SeeAllData == true) while writing test class. I am not able to understand the exact reason for this. Can anyone explain it?

Thanks in advance.
hi i want to validate a phone number field of phone datatype. now my rule is phone number must be a 10 digit number  and it should not be a blank one .....now i used formula NOT(LEN(PHONENUMBER_C)=10).NO THERE IS NO SYNTAX ERROR AND SAVED THE RULE .WHEN I ENTERING IN PHONENUMBER FILED LIKE 9966055438 IT IS A TEN DIGIT NUMBER SO MY RECORD WILL HAVE TO SAVE .BUT AN ERROR WILL COME WHILE SAVING IT AND THAT PHONENUMBER IN DAT FIELD SHOWS LIKE DIS (996) 6055-438.IT IS NOT SAVING WHY THIS HAPPENING ? CAN ANY ONE TELL ME THE REASON   
Hi Everyone,

I have executed a test case in sandbox. But it throws the follwoing error.

Error:
System.QueryException: List has no rows for assignment to SObject

Stack Trace:
Class.TestBulkPricebookOpp.validatepric: line 6, column 1

I couldn't able to resolve it. My test class coding is given below.

@isTest
public class TestBulkPricebookOpp {
    Public static testmethod void validatepric(){
    Id pbID = null;

    pbID = [Select Name, Description From Pricebook2 where Name = 'Bulk Price Book'].Id;
    List<RecordType> recordtypId =  [Select SobjectType, Name, Id, DeveloperName From RecordType  Where SobjectType = 'Opportunity' And  Name = 'k) Bulk Services'];
Account obj = new Account( Name = 'Test', Zip_Code__c='29801');
insert obj;

Opportunity objOpp = new Opportunity(Name = 'newTest',recordtypeId=recordtypId[0].Id,AccountId = obj.Id,StageName ='Prospecting',CloseDate=Date.today());
        objOpp.Pricebook2Id=pbID;       
insert objOpp;

Opportunity objUOppt = new opportunity(Id =objOpp.Id );
update objUOppt ;

}
}


Please any one correct me in the coding part. Thanks in advance.
What is the exact difference between the following annotations?
  • HttpPut
  • HttpPatch
  • HttpPost
Please explain with examples
HI Experts,
Requirement: Delete the  contacts with same account name which i am going to create with before insert event..
I have written this code, but it is not working.. please suggest me ..


trigger Delete_Duplicate_Contact_With_same_accountName on Account (Before insert) {
list<contact> con = [select id, lastname from contact];
for(account a : trigger.new){
if(a.name== con.lastname){
delete con;
}
else{
create a
}
}



Thanks and regards,
Anji
 
public class TEST {
Map<Integer, String> m1 = new Map<Integer, String>();
m1.put(1, 'First item');
m1.put(2, 'Second item');

}
Why do I get this error: Expecting Right Parenthesis found '1'  ??
Hi , I am Getting an error to the old code since we made some changes to the other classes. below is the test Stack Trace. Any help will be really appriciated.
-------------------------------------------------------------------
Error Message System.LimitException: Too many SOQL queries: 101
Class.leadTriggerHandler.assignOwner:line 86, column 1
Class.leadTriggerHandler.onBeforeInsert:line 36, column 1
Trigger.LeadsTrigger: line 4, column 1
public without sharing class leadTriggerHandler {
    
        
     public static void onBeforeInsert(list<Lead> newLeads){
     list<Lead> leadsToProcess = new list<Lead>(); 
        for(Lead l : newLeads){
            
            /* Check if owner is already populated and not currentUser and zipcode is not null, Do_Not_Reassign__c is false
               only then drive the lead through custom assignment rule. */   
            if((l.OwnerId == null || l.OwnerId == userinfo.getUserId()) && l.Zip_Postal_Code__c != null 
                && (l.Products__c != null || l.Facility_Type__c != null)
                && (l.Do_Not_Reassign__c == null || l.Do_Not_Reassign__c == false)){
                    
                leadsToProcess.add(l);
            }else if(l.Zip_Postal_Code__c == null || (l.Products__c == null && l.Facility_Type__c == null) ){
                //no ZipCode match (or) no product and no facility type -  assign the defaultleadOwner.
                l.OwnerId = SystemIdUtility.KCIUSUserId;
            }
        }
        if(!leadsToProcess.isEmpty()){
            assignOwner(leadsToProcess);
        }
     
     }
     
    
     public static void onBeforeUpdate(list<Lead> newLeads, map<Id,Lead> oldValuesMap){
     list<Lead> leadsToProcess = new list<Lead>(); 
        for(Lead l : newLeads){ 
            if(l.Zip_Postal_Code__c != null && 
               (l.Zip_Postal_Code__c!=oldValuesMap.get(l.Id).Zip_Postal_Code__c ||
                l.Facility_Type__c!=oldValuesMap.get(l.Id).Facility_Type__c)){
                    
                leadsToProcess.add(l);
            }
        }
        if(!leadsToProcess.isEmpty()){
            assignOwner(leadsToProcess);
        }
     
     }
     
    
     private static void assignOwner(list<Lead> leadList){
     
     try{
             
             set<String> leadZipCodeSet =  new set<String>();
             list<Lead> clonedLeadsToInsert =  new list<Lead>();
             
                 for(lead l : leadList){
                    if(string.valueOf(l.Zip_Postal_Code__c).length() > 5){
                        leadZipCodeSet.add(string.valueOf(l.Zip_Postal_Code__c).left(5));
                    }else{
                        leadZipCodeSet.add(string.valueOf(l.Zip_Postal_Code__c));
                    }
                 }
                 list<ZIP_Code__c> zipCodeList = [SELECT Name, Is_Active__c, KCI_Territory__c, 
                                                        KCI_Territory__r.Territory_Code__c, KCI_Territory__r.OwnerId 
                                                        FROM ZIP_Code__c 
                                                        where Name In :  leadZipCodeSet and Is_Active__c = 'Y'
                                                        ];
                 for(Lead l : leadList){
                    set<Id> leadOwnerIdSet =  new set<Id>();
                    if(l.Products__c != null){
                        //Product is multiselect picklist and facility is single picklist. For each product and facility, get the JCA from the custom setting
                        for(String product : String.ValueOf(l.Products__c).split(';')){
                            String JCA = '';
                            for(Lead_Assignment_Settings__c las : Lead_Assignment_Settings__c.getAll().values()){
                                if(product.equalsIgnoreCase(String.ValueOf(las.Product__c))){
                                    if(l.Facility_Type__c != null && l.Facility_Type__c == String.ValueOf(las.Facility_Type__c)){
                                        JCA = String.ValueOf(las.JCA__c);
                                        system.debug('@@@ CS Product & FT -- ' + Product + ' -- ' + l.Facility_Type__c);
                                        break;
                                    }else if(l.Facility_Type__c == null && las.Facility_Type__c == null){
                                        JCA = String.ValueOf(las.JCA__c);
                                        system.debug('@@@ CS Product & FT --  ' + Product + ' -- ' + l.Facility_Type__c);
                                    }
                                }
                            }
                            
                            if(JCA != ''){
                                for(ZIP_Code__c zip : zipCodeList){
                                    if( zip.Name == string.valueOf(l.Zip_Postal_Code__c).left(5) && 
                                        zip.KCI_Territory__r.Territory_Code__c != null && zip.KCI_Territory__r.Territory_Code__c.startsWith(JCA)){
                                        
                                        leadOwnerIdSet.add(zip.KCI_Territory__r.OwnerId);
                                        break;
                                    }
                                }
                            }
                            system.debug('@@@ Leads Product & FT -- ' + Product + ' -- ' + l.Facility_Type__c);
                            system.debug('@@@ JCA -- ' + JCA);
                            system.debug('@@@ leadOwnerIdSet -- ' + leadOwnerIdSet);
                        }
                    } else if(l.Products__c == null && l.Facility_Type__c != null){
                        String JCA = '';
                        for(Lead_Assignment_Settings__c las : Lead_Assignment_Settings__c.getAll().values()){
                            if(las.Product__c == null){
                                if(l.Facility_Type__c != null && l.Facility_Type__c == String.ValueOf(las.Facility_Type__c)){
                                    JCA = String.ValueOf(las.JCA__c);
                                    break;
                                }
                            }
                        }
                        if(JCA != ''){
                            for(ZIP_Code__c zip : zipCodeList){
                                if( zip.Name == string.valueOf(l.Zip_Postal_Code__c).left(5) && 
                                    zip.KCI_Territory__r.Territory_Code__c != null && zip.KCI_Territory__r.Territory_Code__c.startsWith(JCA)){
                                    
                                    leadOwnerIdSet.add(zip.KCI_Territory__r.OwnerId);
                                    break;
                                }
                            }
                        }
                    }
                    
                    if(!leadOwnerIdSet.isEmpty() && leadOwnerIdSet.size() == 1){
                        // only one owner idendified for the lead based on product, facility type and zipcode combination
                        l.OwnerId = new list<Id>(leadOwnerIdSet)[0];
                        system.debug('>>>@@@ in lead owner Assignment - Owner = '+ l.OwnerId );
                    }else if(!leadOwnerIdSet.isEmpty() && leadOwnerIdSet.size() > 1){
                        //multiple owners identified, assign the first one to the current lead and create clones to assign to other owners.
                        list<Id> leadOwnerIdList = new list<Id>(leadOwnerIdSet);
                        for(integer i = 1; i < leadOwnerIdList.size(); i++){
                            Lead clonedLead = l.clone(false, true);
                            clonedLead.OwnerId = leadOwnerIdList[i];
                            clonedLead.Do_Not_Reassign__c = true;
                            clonedLeadsToInsert.add(clonedLead);
                        }
                        l.OwnerId = leadOwnerIdList[0];
                        system.debug('>>>@@@ in multi lead owner Assignment - Owner = '+ l.OwnerId );
                    }else{
                        //no owner matching the criteria assign owner to KCI US User
                        l.OwnerId = SystemIdUtility.KCIUSUserId;
                    }   
                 
                 }
                 
                 if(!clonedLeadsToInsert.isEmpty()){
                    insert(clonedLeadsToInsert);
                 }
             
             
     
     }
     catch(Exception e){
     
     }
 
  }

}
----------------------------- 

Trigger 

trigger LeadsTrigger on Lead (before insert, before update) {
	
	if(trigger.isInsert && trigger.isBefore){
		leadTriggerHandler.onBeforeInsert(trigger.new);
	}
	if(trigger.isUpdate && trigger.isBefore){
		leadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap);
	}

}
---------------------------- 

/**********************************************************************************************************************
 * Class Name	: LeadTriggerHandlerTest
 * Description	: Testr Class for LeadTriggerHandler.
 **********************************************************************************************************************/
@isTest(SeeAllData=true)
private class LeadTriggerHandlerTest {
	
    public static Map<String,User> testUsersMap;

    static testMethod void leadOwnerAssignmentTest() {
        Lead testLead = new Lead();
        setupTestData();
        test.startTest();
	        // Test null or blank zip code - owner should be default lead owner KCI US User
	          testLead = createLead('ABThera','Acute','');
	          system.assertEquals(SystemIdUtility.KCIUSUserId, [select OwnerId from Lead where Id=:testLead.Id].OwnerId);
	          
        	// loop through all combinations as configured in Lead Assignment custom setting and create leads with the sample values
        	for(Lead_Assignment_Settings__c las : Lead_Assignment_Settings__c.getAll().values()){
	        	testLead = createLead(String.ValueOf(las.Product__c),String.ValueOf(las.Facility_Type__c),'63000');
	        	if(Limits.getQueries() < Limits.getLimitQueries()-20){
	        		if(testUsersMap.get(String.ValueOf(las.JCA__c)) != null){	
	        			system.assertEquals(testUsersMap.get(String.ValueOf(las.JCA__c)).Id, 
	        						[select OwnerId from Lead where Id=:testLead.Id].OwnerId);
	        		}
	        	}
        	}
        	// update Lead and test Owner assignment.
        	testLead.Products__c = 'Ulta';
        	testLead.Facility_Type__c = 'Acute';
        	update testLead;
        	
        	// Test multiple product
        	testLead = createLead('Specialty Dressing;GRAFTJACKET','Acute','63000');
        	
        	// Test non matching zipcode - then Lead Owner assigned should be KCI US User
        	testLead = createLead('ABThera','Acute','99999');
        	system.assertEquals(SystemIdUtility.KCIUSUserId, [select OwnerId from Lead where Id=:testLead.Id].OwnerId);
        	
        test.stopTest();
    }
    
    private static Lead createLead(String product, String facilityType, String zipCode){
    
    	Lead newLead = new Lead();
    	newLead.FirstName = 'FirstName';
    	newLead.LastName = 'LastName';
    	newLead.Email = 'test@kci1.com';
    	newLead.Products__c = product;
    	newLead.Facility_Type__c = facilityType;
    	newLead.Zip_Postal_Code__c = zipCode;
    	
    	insert newLead;
    	
    	return newLead;
    
    }
    
    private static void setupTestData(){
		//get test users
		testUsersMap = new Map<String,User>();
		list<User> testTMVUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='TMV' and Id !=:Userinfo.getUserId() limit 1];
		if(testTMVUsers!= null && testTMVUsers.size()==1){
			testUsersMap.put('TMV',testTMVUsers[0]);
		}		
		list<User> testTSVUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='TSV' and Id !=:Userinfo.getUserId() limit 1];
		if(testTSVUsers!= null && testTSVUsers.size()==1){
			testUsersMap.put('TSV',testTSVUsers[0]);
		}
		list<User> testSSMUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='SSM' and Id !=:Userinfo.getUserId() limit 1];
		if(testSSMUsers!= null && testSSMUsers.size()==1){
			testUsersMap.put('SSM',testSSMUsers[0]);
		}	
		
		//create Territory and Zip code for test user
		
		//create territory 
    	KCI_Territory__c testTerrTMV=new KCI_Territory__c(Name='terr-01', KCI_Legacy_Id__c='terr-001',Sales_Rep_Id__c=testUsersMap.get('TMV').employee_id__c, 
    	Territory_Code__c='TMV-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('TMV').Id);
    	KCI_Territory__c testTerrTSV=new KCI_Territory__c(Name='terr-02', KCI_Legacy_Id__c='terr-002',Sales_Rep_Id__c=testUsersMap.get('TSV').employee_id__c, 
    	Territory_Code__c='TSV-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('TSV').Id);
    	KCI_Territory__c testTerrSSM=new KCI_Territory__c(Name='terr-03', KCI_Legacy_Id__c='terr-003',Sales_Rep_Id__c=testUsersMap.get('SSM').employee_id__c, 
    	Territory_Code__c='SSM-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('SSM').Id);
    	insert new list<KCI_Territory__c>{testTerrTMV,testTerrTSV,testTerrSSM};
    	
		//create zip codes
    	ZIP_Code__c testZipTMV=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-001',KCI_Territory__c=testTerrTMV.Id,Zip_Start_Date__c=System.date.Today()-5);
    	ZIP_Code__c testZipTSV=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-002',KCI_Territory__c=testTerrTSV.Id,Zip_Start_Date__c=System.date.Today()-5);
    	ZIP_Code__c testZipSSM=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-003',KCI_Territory__c=testTerrSSM.Id,Zip_Start_Date__c=System.date.Today()-5);
    	insert new list<ZIP_Code__c>{testZipTMV,testZipTSV,testZipSSM};
    
    }
}


Class.leadTriggerHandler.assignOwner: line 86, column 1
Class.leadTriggerHandler.onBeforeInsert: line 36, column 1
Trigger.LeadsTrigger: line 4, column 1
Hello,

When inserting Pricebookentry i am getting "standard price not defined" error.
i don't know how to resolve it. if any buddy has idea. please reply me!!!

Thank You.
How to map lead with the existing contact using apex?
In our organization we use the LastName, FirstName and the street address number as the name of the opportunity. For example "Lastname, Firstname1234". Because this is not the default Opportunity name when you convert a lead into an Opportunity, my users need to type this every time they convert a lead. I created a custom convert button, and use a custom URL to load the LastName and the FirstName into the Opportunity Name field, but can anyone help me extract the street number from the street address and add it to the Opportunity Name? My custom URL looks like this:/lead/leadconvert.jsp?retURL={!Lead.Id}&id={!Lead.Id}&noopptt={!Lead.LastName&", "&Lead.FirstName}
Hi Everyone,

I need test calss coding for the trigger involved lead object. Can anyone please write me test class coding.

My trigger is given below.

trigger ReferralPartner_Lead on Lead (before Insert,before update) {   
    Set<String> referrerNames=new Set<String>();   
    for (Lead ld : trigger.new)
    {
        referrerNames.add(ld.Referral_Text__c);
    }
     System.debug('+++referaltext'+referrerNames);
    Map<String, Referral_Partner__c> refPtrsByName=new Map<String, Referral_Partner__c>();
    for (Referral_Partner__c refPtr : [select id, Name from Referral_Partner__c where name in :referrerNames])
    {
        refPtrsByName.put(refPtr.Name, refPtr);
    }
     System.debug('+++===referalName'+refPtrsByName);   
    for (Lead ld : trigger.new)
    {
        Referral_Partner__c refPtr=refPtrsByName.get(ld.Referral_Text__c);
        if (null!=refPtr)
        {
            ld.Referral_Partner__c=refPtr.id;
        }
       System.debug('+++++++++referalPart'+ld.Referral_Partner__c);
    }
}


Please help me on this.

Thanks in advance.

 
Hello Techies,

I have a field on lead where I wanted to store contact owner name created after lead conversion. As we already know that we can not update the converted lead, I am wondering if any one can help if you know any way to update the converted lead.

P.S. Contact owner is changed manually by user once it lead converts to account and contact.

Regards,
Santosh
 
Hi All,

I have already register for dev 401 & just came to know that salesforce credentials for certification are changing from 14 september. I also heard that I need to give transition exam to this new certification credentials if I am dev 401 certified. 
1) is it true and what is the transition exam cost ?
2) should I cancel my exam as I need to give exam twice; one for dev 401 and again for transition ?

Please reply ASAP .

Regards,
Santosh

I want to hide following three elements from dashboard view, how can I achieve it??




User-added image
Hi All,

I have already register for dev 401 & just came to know that salesforce credentials for certification are changing from 14 september. I also heard that I need to give transition exam to this new certification credentials if I am dev 401 certified. 
1) is it true and what is the transition exam cost ?
2) should I cancel my exam as I need to give exam twice; one for dev 401 and again for transition ?

Please reply ASAP .

Regards,
Santosh
Hi Expert,

I'm writing searching function in javascript which allows to search accounts and display them to VF page by using apex:pageBlockTable
I use sforce.connection to query data. I get a list of accounts but i dont know how to pass them to apex:pageBlockTable. Please suggest how to this.
My code is below:
if(search != null) {
                sforce.connection.sessionId = '{!$Api.Session_ID}';
                try{ 
                    var query = "find \{" + search + "\}" + " in all fields RETURNING Account (id, name, billingstreet, billingcity, billingpostalcode)"; 
                    var result = sforce.connection.search(query); 
                    if (result) {
                    	var records = result.getArray("searchRecords");   
                        for (var i=0; i<records.length; i++) {
                           var record = records[i].record;
                         //need to pass value to apex table here

                         }
                                              
                    }
                }  
                catch(e) { 
                    alert('An Error has Occured. Error:' +e); 
                }
            }
Code for displaying account information in VF page:
 
<apex:pageBlockSection columns="1" id="pbs">
                            <apex:pageBlockTable value="{!accounts}" var="account" id="pbt">
                                <apex:column headerValue="Name">
                                    <apex:outputLink value="#" onclick="fillIn('{!account.Name}', '{!account.id}');closeWindow();">{!account.Name}</apex:outputLink>
                                </apex:column>
                                
                                <apex:column headerValue="City" value="{!account.BillingCity}"/>
                                <apex:column headerValue="Street" value="{!account.BillingStreet}"/>
                                <apex:column headerValue="Postcode" value="{!account.BillingPostalCode}"/>
                            </apex:pageBlockTable>
                    	</apex:pageBlockSection>




 
Hi,

I am having a flag which is public variable in the class(with sharing). I am assigning values to that variable inside the constructor of that class and I want to check the value of that flag throughout my application(force.com website). But if I try to access it in another class, the value is coming as null. Can anyone help me with this?
Hi,

We can create the users via dataloader and normal procedure via Administer-Manage Users- Users - New users. ' How to create the platform users via apex ' coding. Please share any example coding here.  
if a class  is with a keyword without sharing.what it going to happen 

what is known sharing rules wont be applicable to that class....

what else more then this ?
will it work in system mode r user mode?
what is diff b/w system mode and user mode
Hello Devs,

I was going through the blogs and salesforce documentation and few blogger's mentioned to avoid using (SeeAllData == true) while writing test class. I am not able to understand the exact reason for this. Can anyone explain it?

Thanks in advance.
I am trying to write a grammar for parsing a SOQL query and while doing that I faced a problem where I need to find the maximum number of Aggregate functions (SUM (FieldName), COUNT (FieldName),... etc.) can be used in a single select clause of a SOQL query. Any help we appreciated. Thanks in advance!!!!!!
hi i want to validate a phone number field of phone datatype. now my rule is phone number must be a 10 digit number  and it should not be a blank one .....now i used formula NOT(LEN(PHONENUMBER_C)=10).NO THERE IS NO SYNTAX ERROR AND SAVED THE RULE .WHEN I ENTERING IN PHONENUMBER FILED LIKE 9966055438 IT IS A TEN DIGIT NUMBER SO MY RECORD WILL HAVE TO SAVE .BUT AN ERROR WILL COME WHILE SAVING IT AND THAT PHONENUMBER IN DAT FIELD SHOWS LIKE DIS (996) 6055-438.IT IS NOT SAVING WHY THIS HAPPENING ? CAN ANY ONE TELL ME THE REASON   
I have one requirement like  below

Have one Picklist with 3 values one of the value Named "REQUEST"   if i select" REQUEST" based on this field i want to update 2 filelds  which is alreday existing the values from other 2 fields.

EX:-
 if i select piklist value  REQUEST means update the A,B Fields whatever the data contains from other 2 fileds C,D.
   A  <--------------C
   B <----------------D

Thanks for your time and effort  :)








i came to know this will possible by Trigger or workflow .....Can some one let me know how can i achieve?

Thanks for your Time and effort
Total newbie to apex. I seem to able to test this trigger fine, but it still runs into governer limits while deploying. Please suggest what can be done to improve the code. 

trigger CheckDeptAllocations on Expense_Report__c (before update) {

    for( Expense_Transaction__c ExpTrans:[SELECT Id, Expense_Amount__c, Allocated_By_Department__c,Amount_Equals_Department_Allocations__c,Expense_Report__c FROM Expense_Transaction__c
                                          where Amount_Equals_Department_Allocations__c=False and Allocated_By_Department__c>0 and Expense_Report__c in: Trigger.new]){
                                          
    If( ExpTrans.Id !=NULL && ExpTrans.Expense_Report__c!= NULL){
    for (Expense_Report__c e: Trigger.New){
        // Check where report status is 'Extracted for Payment'
          if(e.Report_Status__c=='Extracted for Payment'&& ExpTrans.Allocated_by_Department__c>0 && ExpTrans.Amount_Equals_Department_Allocations__c==False) {
                                e.addError('Please make sure all Department Allocations equal the Expense Amount on transactions.');
                return;
           
    }
        
    }
}
}
}
Hi, how to answer if we get a question like, what kind exceptions did you get in your project? can anyone help me on this question?
Hi all,

I'm really new to Apex, so totally clueless right now...

I want to create a related list on Contact that stores all previous Accounts that a Contact has been associated with... To solve this I've created a 'junction' object (called 'Associated Account')) as a M-D of Contact with the following fields:
  • Associated Account Name (Auto Number)
  • Contact (M-D)
  • Account (lookup)
  • Start Date (required)
  • End Date
  • Currently Active (Checkbox - checked by default)
When the Account lookup field on the Contact record is updated, Is it possible to write a trigger that will update a current 'Associated Account' record to uncheck the 'Currently Active' checkbox, and populate the 'End Date'. Then also create a new 'Associated Account' record with the new Account, and Start Date?

In theory it would give an Account history in the related list of each Contact.... is this the best way to attack this challenge?

Many thanks,

Nick
What is this all About?? 
huhCatter??

Thank you
BLearn - Sai