You are on page 1of 3

Delvin's Blog: Two ways to check duplicates

on creation of custom object record

Posted by Delvin - CRMIT Sep 14, 2016


Two ways to check duplicates on creation of custom object record

Option 1:

// check duplicates based on particular fields. (Groovy - Webservice)


// In this eg. Based on two custom fields "Month_c" and "Year_c".

String month = getAttribute('Month_c')


String year = getAttribute('Year_c')

String v_FieldToSearchFor02 = "Month_c";


String v_FieldToSearchFor03 = "Year_c";

String v_Conjunction = "And"


String v_Operator = "="
String objectName = "Target_c"

def findCriteria =
[
fetchStart :0,
fetchSize :-1,
excludeAttribute :false,
filter:
[
conjunction :v_Conjunction,
group:
[[
conjunction :v_Conjunction,
upperCaseCompare :true,
item:
[[
conjunction :v_Conjunction,
upperCaseCompare :true,

1
Delvin's Blog: Two ways to check duplicates on creation of custom object record

attribute :v_FieldToSearchFor01,
operator :v_Operator,
value:
[[
item:resourceName,
]],
]],
item:
[[
conjunction :v_Conjunction,
upperCaseCompare :true,
attribute :v_FieldToSearchFor02,
operator :v_Operator,
value:
[[
item:month,
]],
]],
]],
],
]

def findControl =
[
retrieveAllTranslations :false,
]

def data = adf.webServices.Target_c.findEntity(findCriteria, findControl, objectName)


def checkNull = data[0];
if(checkNull != null)
{
throw new oracle.jbo.ValidationException("Record with this month "+v_FieldToSearchFor02 +"and year
"+v_FieldToSearchFor03 +"already Exists");
return false;

}
else{
return true;
}

Option 2:

2
Delvin's Blog: Two ways to check duplicates on creation of custom object record

While creating custom object


1. check the prevent duplicate values checkbox
2. check the prevent "ABC" and "abc" as distinct values checkbox.

Find the screen shot attached.


• Duplicates.png 41.9 K

2 Views

There are no comments on this post

You might also like