I have a question in regards in what would be the best structure to build a solution based on Lead fields that are compared to a number of custom fields in a custom object in SFDC.
The scenario is that we have four custom fields in the Lead object:
Exterior_Colour__c
,Interior_Colour__c
,Motor__c
andModel__c
.
They are all picklist data type.
Exterior Colour have three options: A, B, and C.
Interior Colour have three options: A1, B1 and C1.
Model have three options: ZP1, ZP2 and ZP3.
Motor have three options: M1, M2 and M3.
On Vehicle__c we also have the same fields with the same values.
What I want is to show on the Lead page layout a section that will select those Vehicle__c records that are at least 80% similar to the picklist values between the Lead record and the vehicles records. I need also to show the similarity percentage on the Lead page between the Lead and Vehilces >= 80%, based on the value entered on the fields mentioned above.
I have been thinking on a few solutions but I can't see a clear structure for this. Initially I though that a trigger on the Lead object would be the best approach but I'm not so sure now. Another solution, that I was thinking, is to create a visualforce page that will be refreshed everytime a user enters a Lead.
What do you guys think will be the best approach for this scenario? Thanks.
@mkorman.
Hello mkorman. Thanks for your input. Yes, it looks like the best option will be go for a component that will be set on the Lead page. There is not problems getting the Lead and obtaining a list of vehicles in connection to that Lead. So are you suggesting to compare the fields and add points to them if a match is found? Something like.
public Integer exteriorColour;
public Integer interiorColour;
public Integer motor;
public Integer model;
public Integer finalPoints;
Map<Vehicle__c, Integer> theMap = new Map<Vehicle__c, Integer>();
for(List<Vehicle_c> v : [SELECT Id, Exterior_Colour__c, Interior_Colour__c, Motor__c, Model__c FROM Vehicle__c WHERE id =: <list of vehicle coming from lead>]){
for(Vehicle__c veh: v){
if(lead. Exterior_Colour__c == veh. Exterior_Colour__c){
exteriorColour =1;
}
if(lead.Interior_Colour__c == veh.Interior_Colour__c){
interiorColour =1;
}……..
finalPoints = exteriorColour+ interiorColour+ motor+ model;
theMap.put(veh, finalPoints);
}
Something like that?