Pages

Wednesday, February 28, 2018

Salesforce: Report result difference because of user Time Zone setting

Scenario:
A same report run by different person, but produce different result.

Possibilities:
1. Record visibility issue (sharing setting)
    negative, because Organization-Wide Defaults is Public read-only
    the user even can open the record not shown in his report.

2. Role Hierarchy filter
    negative, this is not Opportunity report.

Finding:
The report is filtered with a fix date (not relative date). Date in the record is based on User Time Zone setting, and this date applies to reporting too.

User 1 report

User 2 report


User 1 account

User 2 account

User 1 time zone setting is Singapore (GMT +8), while user 2 time zone setting is PST (GMT -8). If you see in the last 2 screenshots, user 1 see the record is created on 28-Feb-2018, while for user 2, it is created on 27-Feb-2018, this will cause the report have different results run by different users.



Friday, February 23, 2018

Salesforce: Setup Overlay Splits Forecast

This blog is only applicable for Collaborative Forecast, not the old Customizable Forecast.

For revenue split forecast, check out this Setup Forecast with Revenue Split. This blog will share on using Overlay Splits Forecast. To enable Overlay Splits Forecasts, here a few things need to perform:

1. Enable Opportunity Team Selling
Search Opportunity Team Settings and enable Team Selling. You can add the Opportunity Team related list to the page layout.



2. Enable Opportunity Splits
- Search for Opportunity Splits, then click Setting.
- Click "Set up Opportunity Splits" button
- By default "Revenue" and "Overlay" are active, no need to change anything here.
- Click Save button and Enable to confirm.
- You will get an email once Opportunity Splits are enabled.
- Add "Opportunity Splits" related list to the page layout.


3. Enable Forecast
- Search Forecasts Settings
- Select "Enable Forecast"
- Click link "+ Add another forecast type"
- Select "Opportunity Overlay Splits"
- Click OK button and Save button



4. Forecast Tab
Now in the forecast tab, click the gear icon, you should see an option for "Overlay Splits"



Once you have opportunity split by Overlay, you will see the number shown in Forecast when select Overlay Splits.

In Opportunity Related List


In Forecast Tab


Reference: Overlay Splits Forecasts in Collaborative Forecasts



Wednesday, February 21, 2018

Salesforce: Mass Upload files to Files using Data Loader

Many years ago, I wrote a blog Salesforce: Mass Upload files to Attachment using Data Loader, that blog explains step by step from preparing CSV file and execute from Data Loader to upload file into Salesforce as Attachment.

In the era of Lightning, "attachment" has been replaced by "files", if you are still using the old "Notes & Attachments" related list in Lightning, the file uploaded from Lightning actually is stored as Files, no longer as Attachment.

1. Prepare CSV file
You can use Microsoft Excel to create new CSV file with following columns:
  • Title - this is text that will show as Title of the file. 
  • Description - (optional) description if the file.
  • VersionData - complete file path on your local drive, example: c:\data\test1.docx
  • PathOnClient - complete file path on your local drive, example: c:\data\test1.docx
  • OwnerId - (optional) file owner, if not provided, owner would be to the user uploading the file.
  • FirstPublishLocationId - this can be Account Id for file need to be linked to Account, or Opportunity Id, or User Id, or Library Id (Library Id start with prefix 058).
  • RecordTypeId - if you define record type under "Salesforce Files" setup menu. To check if you have any record type for Files, query this Select Id, Name FROM RecordType WHERE SobjectType = 'ContentVersion'.
  • TagsCsv - (optional) tag.
A sample of CSV file here.


2. Data Loader
With the latest Data Loader application, you can login to Salesforce with OAuth or Password Authentication, make sure to select "Show all Salesforce objects", then look for object "Content Version (ContentVersion)".


Follow the steps, if no error occurred, all the files listed in the CSV file should be loaded to Salesforce as Files. If you are using Lightning but still using Notes & Attachment related list, you will see the file is appeared in Notes & Attachment too, although technically, it is stored as Files, instead of Attachment.




Reference:


Monday, February 19, 2018

Salesforce: Lightning Experience Adoption Query

So, you are ready to switch to Lightning, but your management decides not to set "Hide Option to Switch to Salesforce Classic" permission. How can you check on how many users have switched to Lightning for good?

Salesforce provides an app you can install from AppExchange Lightning Adoption Tracker, but one of the criteria of this app, that you must enable My Domain.

Once this app installed, you will find a few reports and dashboards added, and a reporting snapshot that needs to be configured, for detail of the steps, see this guide.


Additionally, there are 2 fields added into User object:
“Can Use Lightning”: this custom field stores whether the user has the user permission enabled.
“Using Lightning”: this custom field stores the user preference value.

Can Use Lightning determines how many users have the permission to switch to Lightning, but if you would like to query without installing the package, get it from PermissionSetAssignment object.
SELECT Id, AssigneeId, Assignee.UserName, PermissionSetId, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsLightningExperienceUser = True ORDER BY Assignee.UserName

You need to get unique AssigneeId as this query may report duplicate if the user has more than 1 record permission to enable Lightning. Check this blog Using Permission Set to Query User Permission to learn more about the query on Permission Set.



Using Lightning determines users have switched to Lightning Experience, here is the query from User object without need to install the package
SELECT Id, IsActive, ltnadptn__Can_Use_Lightning__c, ltnadptn__Using_Lightning__c, UserPreferencesLightningExperiencePreferred, Username FROM User ORDER BY Username 


Two fields start with ltnadptn__ are part of Lightning Adoption Tracker packaged installation. Ideally, ltnadptn__Using_Lightning__c and UserPreferencesLightningExperiencePreferred should be the same value, but as ltnadptn__Using_Lightning__c is populated hourly by apex schedule job, so you may see them in sync after an hour.


Reference:


Thursday, February 8, 2018

Salesforce: Reporting on Relate Contact with Multiple Accounts

More than 1 year ago, we wrote a blog about Relating Contact with Multiple Accounts including the security model to add, edit and remove relationship.

In this blog, we'll share how to report Contacts relate to other Accounts, including if they are direct linkage, active, start date, and custom fields added under  Account Contact Relationships.

1. Create Custom Report Type
- From setup menu: search for Report Types by type in the Quick Find box.
- Click New Custom Report Type button
- Select Primary Object = Contacts, you can enter the Report Type Label, Description, and store it under a Category.
- Click Next button to continue



- In Step 2. Define Report Records Set, click relate to another object.
- Select Account Relationships


- Click Save


2. Create Report
- Type the report type name created in step 1 from Quick Find box
- Click Create button
- Here you will find Direct, Active fields under Account Relationship section at left panel
- Save the report and type a report name
- Run the report

For all contacts where Direct is not ticked, they are added from Relate Account relationship.



Here is the screenshot from one of Sean Lee (one of the contact) that not directly link to Ahui Jack account.




For those of you who more interested in the query using SOQL, here a sample:
SELECT Id, AccountId, ContactId, CreatedById, CreatedDate FROM AccountContactRelation WHERE IsDirect = False



Monday, January 22, 2018

Implementing Custom Permission for Workflow and Process Builder

More than 3 years ago, we wrote a blog on implementing Custom Permission for Validation Rules. In this blog, we are going to share the same Custom Permission, but for automation, including Workflow and Process Builder.

We'll not discuss further on how to create Custom Permission and Permission Set, so please check the blog mentioned earlier if you need a reference to create Custom Permission and Permission Set.

Workflow
From Workflow Rule Criteria, select formula evaluates to true.
If you have Custom Permission created, you will see $Permission > under Insert Field.



In this sample, I have a Custom Permission name "Edit_Customer_Custom_Permission", select that permission and add it to Rule Criteria $Permission.Edit_Customer_Custom_Permission.



With this criteria, only users assigned to the Permission Set will trigger the workflow, otherwise, the workflow will not be fired.

Process Builder
Let's use the same Custom Permission - Edit_Customer_Custom_Permission. From Criteria - "Define Criteria for this Action Group"
1. Select Formula evaluates to true.
2. In the Build Formula panel, click System Variable.


3. Select Permission >


4. Type or select the Custom Permission, click Choose button.



5. Now you have the formula built $Permission.Edit_Customer_Custom_Permission.



This is the same criteria with Workflow criteria's above.


Reference: Custom Permission for Validation Rule



Page-level ad