Hot answers tagged

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
  • 481k
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
  • 92.1k
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,295
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
  • 149k
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
Accepted

Batch merging via Apex?

Use a custom object so you can load them quickly. Use a class so you can process those all in one batch go. Because of DML limits, you won't be able to just execute anonymous, unless you feel like ...
sfdcfox's user avatar
  • 481k
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
  • 149k
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
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,934
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.6k
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
  • 149k
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.6k
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
  • 92.1k
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.3k
5 votes
Accepted

When one merges accounts, contacts or leads what happens to lookup relationships?

According to this documentation, they will move: Any related items from any of the duplicate accounts will be associated with the newly merged account.
Sebastian Kessel's user avatar
5 votes
Accepted

How does Pardot Prospect Sync work?

Found it - at least the closest I could find: If you're using a custom field in Salesforce on both leads and contacts, we pull the name of the Salesforce field from the contact field ID. ... We ...
zainogj's user avatar
  • 1,854
5 votes
Accepted

Custom Button Issue

Please change the URL to: /500?rlid=RelatedCaseList&id={!Case.ContactId} And keep the button behaviour as Display in existing window without sidebar or header Please let me know if it works. ...
Shailesh Patil's user avatar
5 votes

Lead Status Converted Value to Contact Status

From the docs: When you convert a lead, data in standard lead fields is transferred into standard account, contact, and opportunity fields. For custom lead fields, the data is mapped to custom ...
Shailesh Deshpande'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,067
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
  • 40.9k
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,570
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.7k
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,295
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,680
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

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