Pages

Thursday, April 26, 2018

Salesforce Email Logs

Few details about Salesforce email logs:
  • Email logs should be available within 30 minutes of your request.
  • Email logs are available for messages sent within the past 30 days before your request. 
  • Each email log can span a maximum of 7 days. To see email log data for a duration longer than seven days, create multiple requests. 
  • Email logs include emails sent through email actions, list email, and mass email, as long as the emails are sent through Salesforce.

In this blog, I'll not share on how to request email log, you can refer to this documentation Request an Email Log, and check this documentation Email Log Reference to understand the format and field values of email log files. I'll share columns need to put attention when you are tracing email send out from Salesforce:

Date Time
The date and time here are always in GMT, so make sure to convert into your timezone if you are checking for specific email at certain times. But, when you request for email logs, enter the time in your local timezone.

Mail Event
D - Delivery: the email was successfully sent to the recipients.
R - Reception: the email was successfully received by Salesforce email server.

Recipient
The email address of the person to whom the email is sent.

Sender
The email address of the person who sent the email, but in many cases, this will not show the exact email address, but mailbox name before @ will be there, example: jjohan=mydomain.com__1l6m60naoh7y3pvy.7zbt7fbfwio41y1c@castgfakbl6ndktj.e2g41.2a-z8jeae.cs47.bnc.sandbox.salesforce.com

Sample:
  • There are 3 color highlights in above screenshot, this is for 3 difference emails.
  • Email received by Salesforce email server (R), then send out in a few seconds (D).
  • The yellow highlight means, there are 3 recipients in that one email, row 7 correspondence to row 3, row 6 correspondence to row 4, and row 5 correspondence to row 2. Each pair has the same Internal Message ID.


When you open email sent in Gmail, you will notice email sender contain a portion of the sender in email logs (see above and below screenshots in pink).


Let's see more columns:

Remote Host
This is IP address of the email server that received the email sent.

Bytes Transferred
The size of the email in "byte", not KB or MB.

Salesforce.com User
The Salesforce ID of the user who sent the email.

Message ID Header
If you are using Gmail, you can check this by click "Show Original"



The screenshot below shows the message header in Gmail, see the highlights in green.



Reference:


Wednesday, April 25, 2018

Salesforce: Opportunity Team Report

Two years ago, I wrote a blog about reporting for the Account Team, this blog would be for the Opportunity Team report. When you use the Opportunity report type, you can filter the result based on the owner, with options:



Let's see the difference between each option. In this sample, I'll login as "Maria Ann" and she has 2 subordinates: "Song Lee" and "Free Man".

My opportunities
All opportunities are owned by me, period!



My team-selling opportunities
All opportunities where I am listed in the Opportunity Team, no matter if I am the opportunity owner or not.



My team-selling and my opportunities 
This is the combination of My opportunities and My team-selling opportunities, although it doesn't mean the opportunity will be listed twice if it fit into both criteria, so you can't just sum the number of opportunity from My opportunities with My team-selling opportunities.



My team's opportunities
All opportunities owned by me and all opportunities owned by users below my role hierarchy, including the indirect reports.



My team's team-selling and their opportunities
All opportunities where I or any users below my role hierarchy were listed as in the Opportunity Team, no matter who owned the opportunity. This is similar to My team-selling opportunities but extended to my subordinates.



My territories' opportunities
Only available when Territory Management is enabled.



All Opportunities
All opportunities that you have visibility.




Filter by Role

Only for Opportunity report type, you can add a filter by Role, where this will filter only opportunities owned by users in the selected role, including users in the subordinates in the role hierarchy.

Additionally, you can narrow by person, by selecting a user name in the selected role hierarchy, this will only be impactful when there is more than 1 user in the same role hierarchy, while all the subordinates are still the same.

Tuesday, April 24, 2018

Salesforce: User License Reporting

We can check the number of licenses purchased and remained from Company Information.



But, can we get the same info using report? With make it as a report, we can schedule to deliver that information directly to stakeholders inbox.


1. Custom Report Type
Salesforce out-of-the-box provides standard User report type, this is good enough to report user information, including login history. But, that report types not able to tell the number of licenses purchased.

Create custom report type and select Users as the primary object. In the Fields Available for Reports, edit the layout and add lookup field from Profiles, and select all fields under Profile. Even, in this case, we just need Name and Total Licenses information.



You may want to change the Total Licenses label by double-click the field, remove "Users: Profile: User License:".



Make sure to set the new Custom Report Type as deployed.


2. Create report
Create a new report using the new report type. To make it looks nicer, set the report as Summary Report, group by User License and filter only for Active users.
You need to create a few 2 custom summary formula:
1. Active Users: to count all active users, the formula: RowCount
2. License Remain: this is by calculating Total License - Active Users, the formula: User.Profile.UserLicense.TotalLicenses:SUM - RowCount


You can add Conditional Highlighting to get user attention when remaining licenses reach a certain threshold.


3. The Moment of Truth



How is the report looks like in Lightning? Except without Conditional Highlighting, the report will still show nicely.




Wednesday, April 11, 2018

Salesforce: Account accessibility

As we mentioned in this blog Contact, Opportunity, Case access, Role Hierarchy play a part in giving Account owner accessibility (view or edit) of Contact, Opportunity, and Case tagged to the Accounts owned by the user.



However, how is the other way round, if the Opportunity (including Contact and Case) is not the same with the Account owner, can the Opportunity owner able to access Account where the user supposed not able to access that account?

The answer is yes, this is called implicit sharing. Salesforce provides implicit sharing between accounts and child records (opportunities, cases, and contacts), and for various groups of portal users.
  • Access to a parent account — If you have access to an account’s child record, you have implicit Read Only access to that account.
  • Access to child records — If you have access to a parent account, you have access to the associated child records. The account owner's role determines the level of access to child records, read this blog Contact, Opportunity, Case access.

However, this does not apply to lookup relationship for custom objects.

If you are still in Classic, you can check the sharing reason, read this blog Sharing Button URL. This implicit sharing will be shown with reason as "Associated record owner or sharing", if you click that link, it will show which records that associated and give the user access to the parent record.



Click "Associated record owner or sharing" link, in this sample, I click "Allison Wheeler".




Reference:

Saturday, April 7, 2018

Salesforce: App Visibility and Query

This blog is written for Apps in Classic, not Lightning apps.

To check app visible and set to default for a user, go to the User Profile, and looks for Custom App Settings.



But, as you may know, in addition to Profile, admin also can assign the user with Permission Set, and additional apps can be added from Assigned Apps.


So, if you would like to trace down apps visible for a user, check user Profile + Permission Set assigned.


App Visibility 
To check an app is enabled for which profiles, open the app page, and click Edit button, scroll down to the bottom and check for Assign to Profiles section, users in the selected Profile will able to see the app.



SOQL
With SOQL, we can query for more apps and profile/permissions set.

1. AppMenuItem
This object store item in the app menu.
Sample query: SELECT Id, ApplicationId, Name, Label, NamespacePrefix, IsAccessible, IsVisible FROM AppMenuItem WHERE Type = 'TabSet' ORDER BY ApplicationId


Id - 0DS prefix
ApplicationId - this is the app Id (prefix 02u)
Label/Name - app label and API name
NamespacePrefix - usually part of a managed package
IsAccessible - if true, the current user is authorized to use the app
IsVisible - if true, the app is visible to users of the organization

2. SetupEntityAccess
When granting a user access to an entity, associate the appropriate SetupEntityAccess records added with PermissionSet that’s assigned to a user.
Sample query: SELECT Id, SetupEntityId, ParentId, Parent.Label, Parent.IsCustom, Parent.IsOwnedByProfile, Parent.ProfileId FROM SetupEntityAccess WHERE SetupEntityType = 'TabSet' ORDER BY SetupEntityId


Id - 0J0
SetupEntityId - this is the app Id (prefix 02u)
ParentId - this is Permission Set Id (prefix 0PS), it can be Profile or Permission Set, check field IsOwnedByProfile. You can use parent relationship queries with . (dot)


By combining the 1st query on AppMenuItem and 2nd query on SetupEntityAccess using Application Id (prefix 02u), you can relate app accessibility with profile and permission set.

Sample: you would like to check all profile and permission have access to Sales app.
1. Query AppMenuItem to get Application Id for Sales app
2. Query SetupEntityAccess to get the list of Profiles and Permission Set for that application id (looks for SetupEntityId)

To enhance this, you can query to object PermissionSetAssignment to get users able to access the app, check out this blog Using Permission Set to Query User Permission.


Reference:


Wednesday, April 4, 2018

Salesforce: Change User Email Address

Whether you’re a Salesforce user or Salesforce admin, you can change the email address in the details on User records to update contact information.

Requirement: Email addresses can only be updated for Users listed as “Active” on the User Detail page.

Once email change in the setup menu, a notification email will be sent to the original email address and a verification email will be sent to the new email address to authorize the change. To apply the update, the user must click the verification link sent to their new email and complete the resulting verification steps within 72 hours.

Please note that this will happen when changing the email address on the user record, including changing the "return address" from the user's personal email settings.



Expected Behavior:
When these fields are updated, you can expect the following:
  • Username: the field is updated and the user receives an email notification, notifying them of the change.
  • Email Address: an email is sent to the new email address so that the change can be confirmed. The field is not updated until the email address owner confirms the change. An email is also sent to the older email address informing the change.
  • Return Email Address: an email is sent to the new email address so that the change can be confirmed. The field is not updated until the email address owner confirms the change.


Reference:

Tuesday, April 3, 2018

Salesforce: Formula Field to view Attachment

This blog is more for Classic, as the attachment is no longer support in Lightning, although existing attachments will be still available in Lightning, you just can't upload the new attachments in Lightning.

Here is the requirement, users would like to have the ability to view the attachment within one click from record page layout, assume only max 1 attachment per record.
By default, you need to scroll down to the "Notes & Attachments" related list, then click the file name, this will open attachment page (00Pxxxxxx), which also show the file size, then click "View file" link -- this is two click from the record page.

Using formula field below, it will show View link when the "id" is available, otherwise, the View link field will not be visible.

IF (NOT(ISBLANK(Attachment_Id__c)),HYPERLINK("/servlet/servlet.FileDownload?file="+ Attachment_Id__c,"View", "_blank"),NULL)

This is to assume that Attachment_Id__c value (a custom text field) has been populated by apex trigger.

The above formula field will work in Lightning, but "_blank" target will not work; the image will overwrite existing web browser window.

Jeff's blog How to Customize Salesforce Attachments explains how to "add" custom fields for Attachment using a custom object, act as a layer between the real object with attachment.