• Tyler Kauffman 18
  • 0 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2

I'm trying to find duplicate records but not actually save a record to the database if there are no duplicates -

The reason is that I'm going to be inserting multiple records (3) wrapped in a database savepoint (transaction control) We dont want the records created unless all three are also created.

Doing this in a lightning component so it's not as simple as setting a global variable{get;set;} so I'm doing a sequence of js promises.. 


below is vaugely  how the duplicate records are being displayed ( at this point it WASNT created because there was a dup found ) but if there wasnt a dup found then it would have been created. 
Apex code is below image on how I plan on solving it unless there are other ideas out there.. Basically if it does save, then rollback database just to turn around and re insert it in a few seconds. Haha

 User-added image


	public static List<sObject> findCustomerDuplicates(Account account){

			Savepoint sp = Database.setSavepoint();
        	List<sObject> duplicateResults = new List<sobJect>();
        	Database.UpsertResult saveResult = Database.upsert(determineAccountType(account), false);
        		for(Database.Error error : saveResult.getErrors()){
        			if(error instanceOf Database.DuplicateError){

        			//handle duplicate error
        			Database.DuplicateError duplicateError = (database.DuplicateError)error;
        			Datacloud.DuplicateResult duplicateResult = duplicateError.getDuplicateResult();
        			//create duplicate result list:
        			Datacloud.MatchResult[] matchResults =

        			Datacloud.MatchResult matchResult = matchResults[0];
        			Datacloud.MatchRecord[] matchRecords = matchResult.getMatchRecords();

        			for (Datacloud.MatchRecord matchRecord : matchRecords) {
        }else{ //is success
        return duplicateResults;
My team is growing in size and am curious on the best approach to source control adoption. We have a good number of apex controllers and rest services.

Does it make sense to just add all apex classes, VF pages, lightning components  to source control
start trying to group related metadata to developer controlled packages (DCP) and source control them that way?

Does anyone have any experiences they can share on their integration of source control for their org? What worked well? what didnt?
I'm following the examples as given in the updated documentation.
    <lightning:recordEditForm recordId="003XXXXXXXXXXXXXXX" objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
Inserting a recordId in the above example results in the following error:
[Error in $A.getCallback() [Cannot read property 'value' of undefined]]
Even the second example, attempting to create a record, is throwing an error:
    <lightning:recordEditForm aura:id="recordEditForm" 
        <lightning:messages />
        <lightning:inputField fieldName="Name" />
        <lightning:button class="slds-m-top_small" type="submit" label="Create new" />
In the above code, there are two separate errors happening:

1) I'm getting the error 'Cannot read property 'defaultRecordTypeId' of undefined' even though there are no record types associated with my Conatct object.  To get around this error, I have created a record type and I'm now passing in the recordTypeId.  Updated code looks like:
    <lightning:recordEditForm aura:id="recordEditForm" 
        <lightning:messages />
        <lightning:inputField fieldName="Name" />
        <lightning:button class="slds-m-top_small" type="submit" label="Create new" />
2) Now that I'm past the recordTypeId error, I now receive this error:
cannot read property 'fields' of undefined

I understand that this new component is in Beta for the current release, but I wanted to understand if the documentation is incomplete, if I'm making some simple error that I cannot see, or if the feature is not fully functional yet.