We are an Airline Org. When a passenger comes on web to create a case, he has to provide certain details which are not mandatory on the web.

So if a passenger A comes to web and decides to provide his wrong Document number say 11111111 with his first name and last name,we create a client in Salesforce with that name and document number(if he doesn't already exist as client) and links the case with him.

Now a passenger B comes for claims on web and decides to give his document number again as any random number say as 11111111. Now in this case what happens is we create a case and attach it to Passenger A.

Since we think the document number 11111111 is for Passenger A. How can we apply a stringent check?

Since First name and last name can be same for people we cannot apply that check.

  • Where it is hosted this web2case page? Is it any salesforce portal or any other portal developed in different language? Sep 16, 2018 at 18:17
  • Do you have the actual document numbers in Salesforce? Any chance they're linked to who they've been sold to? Sep 16, 2018 at 18:39
  • @SantanuBoral Its hosted on other Portal developed in a different language.There is not much check that we can put up there because that's how the clients come for our Org so we cannot put acheck there which will stop Passengers raisng their Claims. Sep 16, 2018 at 19:16
  • @ShaneSteinfeld Yes if the Client already exists, we have their Document of Identity.And if the customers provide their actual Document number,we link the case to current client. Its happening for 8-10% of customers who doesnt provide their correct Document number.And today we have diferent patterns (11111111,00000000,11112222 etc) First time with that document number a client is created and every subsequent customers who provide fake 11112222 doc number, their cases are attached to customers whco had first provided that doc number 11112222. Sep 16, 2018 at 19:22

2 Answers 2


You need to put a unique check based on first name, last name and document number. Create a unique field to store those information together.

So, if you are a validating document number during creation of case, verify that document number is attached to valid first name and last name. Next time, if customer enters combination of wrong document number or first name or last name then don't create cases.

If you are capturing email addresses of the customer, then after creation, you can send the case number otherwise, if any error occurs due to invalid condition then also, send a failure notification.


It's not perfect, but this should give you a fairly accurate idea about whether the name and document number match a combination in the database without relying on an exact name match...which, as you eluded to, is no good:

First, do a search for the document number using LIKE instead of an exact match.

SELECT Name, Document_Number__c FROM ______ WHERE Document_Number__c LIKE '%11111111%'

Then, for each document number returned, see how far off the name value is. (Concatenate first and last name if they're in separate fields, and then check the concatenated value.) If fewer than...say 30%...of the characters in the name are wrong, consider it a match. You can play with the percentage until you get to a reasonable match tolerance.

String name = FirstName + LastName;
Integer nameLength = name.length();
Integer tolerance = (Integer) (nameLength * 0.3).round(RoundingMode.UP);

// getLevenshteinDistance will return -1 if the name match is higher than the tolerance level.
Integer deviation = getLevenshteinDistance(name, tolerance);

if(deviation < 0){
    // name is a mismatch

  • Did you find a solution to the matching problem? Curious to hear what you ended up doing! Sep 30, 2018 at 21:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.