Skip to content

Instantly share code, notes, and snippets.

@karanrajs
Created February 16, 2015 18:22
Show Gist options
  • Save karanrajs/307a0202d47c6eaebb93 to your computer and use it in GitHub Desktop.
Save karanrajs/307a0202d47c6eaebb93 to your computer and use it in GitHub Desktop.
Trigger to call the Flow
trigger DuplicateCheck on Account (before insert,before update) {
for(Account acc: Trigger.New)
{
Map<String, Object> params = new Map<String, Object>();
params.put('varAccountName',acc.Name);
params.put('varAccountId',acc.Id);
Flow.Interview.DuplicateAccountCheck duplicateAccountCheck = new Flow.Interview.DuplicateAccountCheck(params);
duplicateAccountCheck.start();
// Obtain the results
String returnValue = (String) DuplicateAccountCheck.getVariableValue('varReturnAccount');
if(returnValue != null && returnValue != '')
acc.Name.Adderror('Duplicate Account Found with the same Name: '+returnValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment