Component.find behavior that you know but may not comply with

You may know that find() method may return a single object or a list object. But I realized that many developers do not carry about cases when the find() method may return only one object and it causes the ".forEach is not a function" error. It happens because the find() method found only one match, and in this case, return a single object. It's because the forEach() method is not a function for an object, it's only available for lists. However, there exists a simple workaround how to fix that :)

let myResult = component.find("myParam");
myResult = [].concat(myResult);
// myResult is a list now, and you can use the forEach() method

Useful links:

UNKNOWN_EXCEPTION, INVALID_TYPE: sObject type 'SalesforceIqDataSource' is not supported.

Why is it failing now? We do not change code for the long period
It starts failed after activation the "Einstein Activity Capture" feature.

What functional is affected by this issue?
It affects only the send email functionality for the site guest user. So, if you have force.com site and it calls apex code to send an email, then the logic will fail. Please note that workflow email alerts work successfully, affected only apex part.

Are there any workarounds?
You can deactivate the "Einstein Activity Capture" feature but if it is not a solution, then log a Salesforce case. Please note that support can help you only if you have Premier Customer Support. In this case, please ask them to whitelist the SalesforceIqDataSource object. Whitelisting for the guest user is performed by the Developer Team, and this is available only to Premier Customer.

Useful links:

System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop

It's a surprise to me, I do not expect to receive the exception in the next code block. But it happened when a number of child records greater or equals to 200.

for (Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account]) {
    System.debug(p.Contacts.size()); // throw exception			
}

Here is the way how you can avoid this exception, just use FOR to calculate a number of children. It’s not graceful, but it works.

for (Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account]) {
    Integer numberOfContacts = 0;
    for (Contact c : a.Contacts) {
        numberOfContacts++;
    }
    System.debug(numberOfContacts);		
}

Useful links:

Getting #Error in a formula field when using exponentiation

Do you know that power should be integer number? Otherwise, you will get #Error in a formula field. It was a surprise for me because I didn't find something like POW or POWER function that accepts double power value. Luckily, Salesforce support EXP(returns the value of e to the specific power) and LN(returns the natural logarithm) functions in formula fields. Now when we know it all, let's think about how we can use it.

Mathematics will help us, based on the information that e ^ (ln a) = a, we can rewrite a ^ b to the next format:

A ^ B = e ^ (B * ln(A)) = EXP(B * LN(A))

Useful links: