16
votes
Accepted
trigger to find change in contact role for an opportunity
Well, you've probably figured out by now that Triggers aren't supported on OpportunityContactRole (OCR). And, when an OCR is CRUD'd, there is no trigger that fires on the Opportunity either.
There is ...
13
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&...
11
votes
Accepted
Replace new line character in textArea field in Apex
It depends on which character is used (that differs between operating systems). If you use these three (make sure the \r\n one is first) it should work:
street = street.replace('\r\n', ' ');
street = ...
10
votes
Accepted
Contacts without Accounts: Is it possible, and if not, why?
Your understanding is correct; SFDC unashamedly assumes you're using a standard Sales-y workflow with Accounts and Contacts.
I'm not sure there's a really good alternative here. Some options might be:...
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 ...
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 ...
8
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 ...
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 ...
7
votes
Accepted
Linking Account to Contact in Apex
Records don't have IDs until they are inserted. You need to insert the Account first and then specify the Account's ID in your Contact, otherwise they won't be linked.
public PageReference doSave() {
...
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 ...
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 ...
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. ...
7
votes
Accepted
Marketing Cloud ContactID, where do I find this?
This would be SubscriberID on the _Subscribers view.
6
votes
Accepted
Contact-Accout Name Field
You don't see the Accounts you own, rather you see the Account Records which you have recently viewed.
And No I don't think you can see all account records in that lookup list, you will only see ...
6
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 ...
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 ...
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 ...
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.
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 ...
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 ...
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 ...
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.
5
votes
Accepted
Export to excel file problem with displaying information
Try this,
<apex:dataTable value="{!acc}" var="a">
<apex:column value="{!a.ID}"/>
<apex:column value="{!a.Name}"/>
<apex:column>
<apex:...
5
votes
Replace new line character in textArea field in Apex
Same answer as rael_kid, but in one regex:
replaceAll('\r\n|\n|\r',' ');
5
votes
Accepted
Multiple Contact 'types' on a Custom Object: Model with junction object or specific lookup relationships?
@greenstork is correct, there really is no true correct answer, its just a two options and each has pros and cons.
The main difference in options is that Option 1 would be a many-to-many and Option 2 ...
5
votes
deduping existng leads and contacts
The two most highly rated free de-duping Apps on the App Exchange are Dupe Catcher and Duplicate Check. Some of the features in the latter are available only in the paid version while everything in ...
5
votes
Accepted
Stop Salesforce Standard UI Phone Number field formatting (on blur)
Use a + at the beginning of a number to prevent automatic formatting. There isn't a reliable way to prevent this automatic formatting otherwise without code. For exaample +41251351415 will remain that ...
5
votes
How to get Opportunities from Contacts
This field is a bug and should not be used. It is technical debt that SFDC has not cleaned up yet. Mary Scotton at SFDC commented on this here: http://gokubi.com/archives/mystery-contact-id-field-on-...
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.
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
contact × 686account × 143
apex × 122
trigger × 78
marketing-cloud × 72
soql × 54
opportunity × 49
visualforce × 34
leads × 31
rest-api × 26
email × 26
case × 25
lookup × 24
community × 20
custom-object × 18
campaign × 18
page-layout × 17
opportunitycontactrole × 17
lead-conversion × 16
contactbuilder × 16
api × 15
journeybuilder × 15
sharing × 14
user × 14
relationships × 14