i want to make validation for duplicate Entry ,
For Example- I have make from Studio Custom Module [Program ]And I want to validate to duplicate entry in data base
i want to make validation for duplicate Entry ,
For Example- I have make from Studio Custom Module [Program ]And I want to validate to duplicate entry in data base
Hi,
I think we can try using the rest api end points and retrieve duplicates and validate fields in record and create view.
Hope this helps.
Regards
Sidhu
Hi M kumar
Go throught this link its helps you :- How to add custom field in Find Duplicates Section of the Module
Hi M kumar
In Sugar 7, you can use the Duplicate Check Framework, to customize the way the DuplicateCheck API Endpoint checks for Duplicates on a particular module, by following the instructions listed here: http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.7/Architecture/Duplicate_Check/
The Duplicate Check Framework utilized the FilterAPI Framework to search for other records baed on criteria you specify. The DuplicateCheck API Endpoint is called when creating records in a Sugar 7 Create View by default, and brings up the duplicate records that are found based on your defined filter class.
Regards,
Michael Russell
Developer Support Engineer
hi
i Am unable to do that ...
i want to do Stop duplicate entry to the database ..
when entered Duplicate name display message duplicate record.
i have a custom module that has fields name and Description,and contact name and director name
Hi M kumar
Is this problem resolved?
If no then are you looking for removing "ignore duplicate and save" Button.
If this is what you are looking then check this post Remove/disable "ignore duplicate and save" button
Regards
Sam Roy
Hi M kumar
This link helps you for prevent duplicate records.
Hi MK Gupta,
I want to share with you one solution which works if you just want to avoid duplicate entries for a given module without using the duplicate check feature of SugarCRM. Unlike the duplicate check default feature of Sugar,this solution does not let you to duplicate the record (it just triggers an error telling you that the record is duplicated).
This solution is for the Accounts module and what it is checking if the name of the account is equal as the new account, so if they are the error will be shown to the user.
Here is the definition of the LogicHook located at custom/Extension/modules/Accounts/Ext/LogicHooks/validate_duplicate_record_lh_definition.php:
$hook_array['before_save'][] = Array(
//Processing index. For sorting the array.
1,
//Label. A string value to identify the hook.
'validate_duplicate_record',
//The PHP file where your class is located.
'custom/modules/Accounts/scripts/validate_duplicate_record_lh.php',
//The class the method is in.
'ValidateDuplicateRecord',
//The method to call.
'validateDuplicateRecord'
);
Here is the code of the LogicHook:
require_once 'include/api/SugarApiException.php';
require_once 'include/SugarQuery/SugarQuery.php';
class ValidateDuplicateRecord {
//Checks if the account name already exists
function validateDuplicateRecord( $bean, $event, $arguments ) {
if( !$bean ) {
return;
}
$accountId = $bean->id;
$accountName = $bean->name;
$duplicateAccountMessage = 'Error: An account with name "' . $accountName . '" already exists';
$accountBean = BeanFactory::getBean( 'Accounts' );
$sq = new SugarQuery();
$sq->from( $accountBean, array('team_security' => false) );
$res = $sq->execute();
foreach( $res as $index=>$account ) {
if( $account['id'] !== $accountId && $account['name'] === $accountName ) {
throw new SugarApiExceptionInvalidParameter($duplicateAccountMessage);
}
}
}
}
Hope this helps,
David.
Thanks MK S...
HI M kumar
If that answer really helped you.. mark it has Answer Correct