Skip to main content
14 votes
Accepted

How to efficiently combine 2 Lists<Contact> if the same Contact is in both

Here's how'd I do it: public static SObject[] mergeData(SObject[] list1, SObject[] list2) { Map<Id, SObject> results = new Map<Id, SObject>(); for(SObject[] recordList: new List&...
sfdcfox's user avatar
  • 500k
10 votes
Accepted

Delete an SObject by knowing only Id

Yes, you can delete an object knowing only its Id. If you know the object's type at development time, you can initialize an sObject instance with the Id and supply it to the delete DML operator, as ...
David Reed's user avatar
  • 93.4k
10 votes

Query All contacts for mass contacts delete

No need to create a support case, this doc has ways to accomplish your use case: 'Permanently remove Contacts or Subscribers and associated data from Contact Builder' Prepare to delete any Contacts ...
EazyE's user avatar
  • 8,602
10 votes
Accepted

Marketing Cloud ContactID, where do I find this?

This would be SubscriberID on the _Subscribers view.
didntStormArea51's user avatar
9 votes
Accepted

Inserting Accounts and Contacts Simultaneously

If you have an External Id field on Account that you can specify, you can set the relationship via the Name Pointing Field (Account). String externalId = '<some_value>'; Account ...
Adrian Larson's user avatar
  • 151k
8 votes
Accepted

The length of the first and last names

A quicker way to do that is to use describe call in Apex. System.debug(Contact.FirstName.getDescribe().length); //Prints 40 System.debug(Contact.LastName.getDescribe().length); //Prints 80 It also ...
Pranay Jaiswal's user avatar
7 votes

How to write a soql query will give you accounts that have any contacts and get the contacts

I recommend you read A Deeper look at SOQL and Relationship Queries on Force.com. Everyone who works with Apex probably should. In addition to the Left Inner Join you have in your WHERE clause, you ...
Adrian Larson's user avatar
  • 151k
7 votes

GDPR: What happens to deleted contacts re-entered through imports

You would need to remove their address/contactkey from your system as well to stay GDPR compliant. The Marketing Cloud will allow the contact key back into the system after it has been fully deleted. ...
jzehner's user avatar
  • 101
7 votes

How to check object name by objectId?

You don't need the Describe API. Just use the Id class's methods. Adapted from the documentation: Contact a = new Contact(LastName = 'Test'); insert a; Id myId = a.id; System.assertEquals(Contact....
David Reed's user avatar
  • 93.4k
6 votes

Replace new line character in textArea field in Apex

Same answer as rael_kid, but in one regex: replaceAll('\r\n|\n|\r',' ');
Jaap Scheper's user avatar
6 votes
Accepted

get all task related to contact in developer console

You will need to SOQL Contact first then feed the Tasks List with those ContactIds to get the related Tasks. Contact SOQL Contact[] cons = [SELECT id from Contact ]; Now, feed these ContactIDs to ...
Mahmood's user avatar
  • 5,976
6 votes
Accepted

How to query Account object with minimum number of children?

That can be a difficult query since Accounts and Contacts typically have a lot of records. There's a risk of running into the "Too many query rows" exception, but if you don't have too much data at ...
martin's user avatar
  • 12.7k
6 votes
Accepted

No such column 'ReportsTo' on entity 'Contact'

The field name is ReportsToId, which you can see for yourself in the SOAP API Developer Guide page for the Contact object.
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Allow communities user to see multiple Accounts

Yes, sharing sets now support the Contacts with Multiple Accounts feature. Let’s say you create a community or portal user from a contact that is associated with multiple accounts. You can then create ...
sfdc's user avatar
  • 13.7k
6 votes

Fire Journey Builder when Contact Object is Updated

The documentation is a little misleading when it states: "The rule does not run when a record that previously met rule criteria is updated". Makes it sound like a record can't qualify again. So for ...
Josh de Blank's user avatar
6 votes
Accepted

SOQL - Select only contacts that have related Opportunities

This is a good place to apply a semi-join pattern, which is the most common query tool used to limit a query by the presence or absence of related objects. It is made only a little bit more complex ...
David Reed's user avatar
  • 93.4k
6 votes

The length of the first and last names

you can check details about fields on Contact SOAP API guide FirstName - The contact’s first name up to 40 characters. LastName - Required. Last name of the contact up to 80 characters.
Oleksandr Berehovskyi's user avatar
6 votes
Accepted

Why is the LastName field required for the contact? What is the best approach to import contacts that only have the first name?

As for the LastName being mandatory, I can only say that it's by design. And seems there were ideas to get it optional, but Salesforce doesn't have any plan to do so. So it is very unlikely we can get ...
Jayant Das's user avatar
  • 30.6k
5 votes

NPSP did not create an account

When you import contacts that are donors into the NPSP, there's a NPSP Data Import Object that you want to import them into first after which you can run the Nonprofit Starter Pack Data Importer Tool ...
crmprogdev's user avatar
5 votes
Accepted

SOSQL Query for Contacts and Contact Roles

See the blog for SOQL subquery You can use a inner query to achive this. Try this code: List<Account> accountList = [Select Id, Name,(Select id from AccountContactRoles), (Select Id from ...
Devendra's user avatar
  • 5,085
5 votes
Accepted

Is it possible to retrieve list of Accounts which has more than 100 contacts associated to it using a single SOQL?

Solution 1 You can do this in single soql via : Select AccountId from Contact group by AccountId having count(Name) > 100 Solution 2 You have to create a roll-up summary field on account object ...
Pragati Jain's user avatar
  • 1,580
5 votes

How to query Account object with minimum number of children?

You can try following query: SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN (SELECT AccountId FROM Contact) What you have missed is having AccountId in outer join. Update: If ...
Raul's user avatar
  • 18.9k
5 votes
Accepted

Avoiding creating duplicate Contacts in Marketing Cloud when using Sales Cloud records

Generally speaking, we create Automations that do a Query/Extract/Import to All Subscribers for any email address that's associated with an unsubscribed Subscriber Key. This obviously doesn't prevent ...
Adam Spriggs's user avatar
  • 30.9k
5 votes

Marketing Cloud - Lead becomes Contact

There is a process for this, although it isn't documented externally. You can reach out to support or your local salesforce contact and ask about "Marketing Cloud Alternate Key Store" If you follow ...
Kenneth Wagner's user avatar
5 votes

Can I delete message on Mobile Connect?

Once a message is marked inactive after 180 Days it will be deleted by the system. This is covered in this help doc: Inactivate a Message NOTE After 180 days, MobileConnect archives inactive messages ...
EazyE's user avatar
  • 8,602
5 votes
Accepted

Does contact deletion in marketing cloud also removes email tracking data?

The information will remain in the system - but in unrecognizable format. Contact deletion does also not remove the Contact (any any related information) from your custom non-sendable Data ...
Rain's user avatar
  • 5,785
5 votes
Accepted

SFMC Duplicate Contacts Query

Row_Number() is one of the more useful functions for everything relating to deduping. This will number your duplicates and from the result of the numbering, select all those that do not have the ...
Jonas Lamberty's user avatar
5 votes
Accepted

How to remove a record from being created using Before Insert?

You can't "remove" these records; you'll specifically get a System.FinalException error for trying to modify Trigger.new's size in any way. By the time your trigger runs, the system has ...
sfdcfox's user avatar
  • 500k
5 votes
Accepted

Is there any way of retrieving all records from a data extension via REST API for Marketing Cloud?

There is an undocumented endpoint for getting records from a Data Extension using REST, with a filter defined by request parameters to the endpoint: GET /data/v1/customobjectdata/key/YOURDEEXTERNALKEY/...
Lukas Lunow's user avatar
  • 21.9k
5 votes

Apex Trigger 'Expression cannot be assigned'

OppObj.StageName = 'Quoted' && OppObj.Contact__r.Status__c = 'Sales Qualified') Comparisons for equality use ==. = is an assignment. You have more problems here, though. if(...
David Reed's user avatar
  • 93.4k

Only top scored, non community-wiki answers of a minimum length are eligible