Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Duplicate matching and API calls #4

Closed
Btibert3 opened this issue May 26, 2018 · 5 comments
Closed

Feature Request: Duplicate matching and API calls #4

Btibert3 opened this issue May 26, 2018 · 5 comments
Assignees
Labels
enhancement Feature request
Milestone

Comments

@Btibert3
Copy link

This appears possible given https://salesforce.stackexchange.com/a/66926/18334, but more generalized, my use-case is to check to see if a lead or contact reasonably exists relative to the data I would be sending to my partner's org via API.

@StevenMMortimer StevenMMortimer self-assigned this May 26, 2018
@StevenMMortimer
Copy link
Owner

Great suggestion, @Btibert3. I think there are two different enhancements that need to be made to round this out in the package:

  1. Add 3 new function arguments to sf_create(), sf_update(), and sf_upsert() that would control the DuplicateRuleHeader so that users can leverage the duplicate matching rules when creating records.
Argument Name Type Description  
allowSave boolean For a duplicate rule, when the Alert option is enabled, bypass alerts and save duplicate records by setting this property to TRUE. Prevent duplicate records from being saved by setting this property to FALSE.
includeRecordDetails boolean Get fields and values for records detected as duplicates by setting this property to TRUE. Get only record IDs for records detected as duplicates by setting this property to FALSE.
runAsCurrentUser boolean Make sure that sharing rules for the current user are enforced when duplicate rules run by setting this property to TRUE. Use the sharing rules specified in the class for the request by setting this property to FALSE. If no sharing rules are specified, Apex code runs in system context and sharing rules for the current user are not enforced.
  1. Add the findDuplicates() method from the SOAP API that allows users to simply check if there are matching records based on the object's duplicate rules without any fear of actually creating new records. That is the fear/issue that some Stack Exchange readers had with the first answer in that post.

@StevenMMortimer StevenMMortimer added the enhancement Feature request label May 26, 2018
@StevenMMortimer StevenMMortimer added this to the 0.1.3 milestone May 26, 2018
@Btibert3
Copy link
Author

Awesome, I will try to poke around the code, but not sure far I will get. That said, this is a terrific road map.

@StevenMMortimer
Copy link
Owner

@Btibert3, better late than never, I’ve implemented two functions that will find duplicates using duplicate matching rules that have been set up in your org:

I’m still working on a more global way to control all the header options as mentioned in item number 1 of my comment above where you would be able to control things like the allowSave header for sf_create(), sf_update(), and sf_upsert(). Hopefully that will all be included in a more stable build and CRAN release that should be coming soon this summer.

@Btibert3
Copy link
Author

Btibert3 commented May 15, 2019 via email

@StevenMMortimer
Copy link
Owner

@Btibert3 The latest CRAN release of the package (0.1.3) has sf_find_duplicates() and sf_find_duplicates_by_ids(), but also many functions now also accept a control argument. This is what I mentioned in item number 1 in my comments above where you can specify headers that fine-tune the behavior of your API calls. In the example below, I have a duplicate email rule for Contacts turned on in my org, but I can override it by using the DuplicateRuleHeader.

# create duplicate records 
new_contacts <- tibble(FirstName = rep("Test", 3), 
                       LastName = rep("Contact", 3), 
                       Email = rep("test.contact@gmail.com", 3),
                       Description = c("Contact 1", "Contact 2", "Contact 3"))
# insert the records
new_recs <- sf_create(new_contacts, "Contact", 
                      DuplicateRuleHeader = list(allowSave = TRUE,
                                                 includeRecordDetails = FALSE,
                                                 runAsCurrentUser = TRUE))
new_recs
## # A tibble: 3 x 2
##   id                 success
##   <chr>              <lgl>  
## 1 0036A00000wzoYQQAY TRUE   
## 2 0036A00000wzoYRQAY TRUE   
## 3 0036A00000wzoYSQAY TRUE

Essentially, any of the API headers can be passed into the function call from R. In this case, the DuplicateRuleHeader allows you to bypass the rules that might block the creation of the record. There are over a dozen control parameters that are now possible across the various APIs. Those are documented at https://stevenmmortimer.github.io/salesforcer/reference/sf_control.html

There is also a vignette which describes all of this in more detail https://stevenmmortimer.github.io/salesforcer/articles/passing-control-args.html and a blog post I wrote highlighting the updates in version 0.1.3 of the package: https://stevenmortimer.com/salesforcer-0.1.3-features-for-better-crm-data-management

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request
Projects
None yet
Development

No branches or pull requests

2 participants