Pages

Thursday, June 13, 2013

Salesforce Joined report: Using the same Report Type in multiple Block

If you are using Salesforce Enterprise or Unlimited edition, Joined Report has been introduced sometimes back, with some limitations, slow performance, and need some improvements. But, in some business cases, we can take advantage of using this joined report.

The joined report format lets you view different types of information in a single report. A joined report can contain data from multiple standards or custom report types.

To get started with joined reports, create a new or edit an existing report in report builder, click the Format drop-down, and choose Joined. Most of the things you can do with summary or matrix report you can also do with joined reports. For example, you can find, add, and remove fields; summarize fields, and run and save reports. You can show a joined report that includes a chart on a dashboard.

We can easily add a new block with a different type by clicking the "Add Report Type" button, and it will create a new block and users can group the "common fields".

But, how we can have multiple blocks with the same object? Easy.... just drop a field at the right of the last block. See this video on Youtube.


Saturday, June 8, 2013

Salesforce: Private Contact & Person Account

Private Contact
By default, Salesforce allow Contact do NOT link to Account, unless you set Account as required in Contact Page Layout or Validation Rule.

Although Account sharing rule is Public (Read Only or Read/Write), for a Contact without linked to Account, regardless what is the Contact sharing rule, it is considered as Private contact, meaning: only contact owneruser with View All Data and View All [on Contact objectpermission able to see the Contact, while all other users will not able to see the contact (even if the user copy and paste Contact URL, he will get error message: Insufficient Privileges), and the contact will also not shown in the search result and report.

Sharing rules and workflow rules do not apply to private contact, you also cannot manually share and enable self-service for those contacts, both buttons will not be visible.

So in summary, it is not a good idea to leave Contact without Account. You can request Salesforce Support to enable Person Account for such scenario. Using an account as place holder is not a good idea as well, as the number of contacts linked to that place holder account growth, it will cause data skew issue.


Person Account
If you enable Person Account, contact sharing in Organization-Wide Default for Contact will be automatically change to Controlled by Parent and this is not editable. So, if you just enable Person Account, Organization-Wide Default for Contact will be changed to Controlled by Parent, this will remove all existing contact sharing rules and manually shared contacts.




Friday, June 7, 2013

Salesforce: Opportunities in Campaign

One of my users came to me and asked why Opportunities in Campaign is not tally with Lead added to that Campaign and converted into Opportunity?

Here is the cause:
  • One Lead can be added to multiple Campaigns
  • But only the last Campaign associated with the Lead prior to the lead conversion will be brought into Primary Campaign Source in Opportunity
  • When a Lead is converted, the Primary Campaign Source in Opportunity will be populated with the last Campaign associated with the Lead prior to the lead conversion
Opportunities in Campaign are counted by the number of opportunities with the Primary Campaign Source tagged to that Campaign.

Sample screenshots:

In Campaign:




Report with report type = Opportunities




The last questions surface, how do we know which is the latest Campaign associated with a Lead or a Contact?

Easy... look at the Campaign History related list in the Lead or Contact page layout (make sure the Campaign History related list has been added) and look for Member First Associated.



For other related fields, a sample of order Lead/Contact added to Campaigns
  1. Add Jeryl Ma (lead) to 1st campaign
  2. Add Lia Lee (lead) added to 2nd campaign
  3. Add Lia Lee (lead) added to 1st campaign
  4. Add Jake Llorrac (contact) to 2nd campaign
  5. Add Tom James (lead) to 1st campaign

Result:

Notes:
  • Converting lead Lia Lee with creating a new opportunity will populate Primary Campaign Source in the Opportunity with "1st Campaign" because the "1st Campaign" is the last campaign for Lia Lee.
  • Converting lead Lia Lee with creating a new contact will increase the number of Contacts in Campaign, but not reduce the number of Lead in Campaign.


Last update: 27-Mar-2023




Salesforce Search on Object and Chatter

In previous blog, we blog about searchable field types in Salesforce. Today we'll continue with more information on Search.

Salesforce will keeps track of which objects you use and how often you use them, and arranges the search results accordingly. Objects you use most frequent will appear at the top of the list. If you do not see the object, click Search All at link.


Options
After you search something in Salesforce, you will see Options in search result page. From here, you can restrict search result only to records you owned.

Keywords
Salesforce search is case-insensitive for the whole data.

Wildcards and Operators
You can use the * (asterisk) and ? (question mark) wildcards to refine results. Use * to match one or more characters, or ? to match a single character. For example, searching for bob jo* finds items with Bob Jones and Bob Johnson, and searching for jo?n finds items with john and joan. You can also use the AND, OR, AND NOT, ( ) (parentheses), and " " (quotation marks) operators to refine results.
Sample: johan AND (singapore OR Indonesia); please note: operator support is case-insensitive.


But, my search result still do not shown records from a custom object. Why? This is usually happened because administrator do not create tab for that object. That is why Salesforce search function will not search custom objects if the objects don't have tab. For more info related to this, read this blog Global Search Result on Custom Object.


Chatter Search
If your company have Chatter enabled, Global search also returns Chatter feed result. From above screenshot, click "Search Feeds" link. This results include all relevant public posts, including posts from people you are not following and from public groups you are not a member of. In other words, Global search return more feed information compare to if you search individual feed (Chatter home feed, record feed, group feed).

To search only from a particular feed, use the "Search in Feed" magnifying glass, if you type more than 1 word, it will search words appear together, as well as they appear separately.

Chatter Feed in Home tab

Feed in Chatter tab

Another way to search in Chatter by using Topic, it will show all post or comment tagged with the topic, even from people you are not following, or group you are not a member of.  You also can follow the topic, so when someone use that topic, it will appear in your feed.

Bookmark is another option to follow a post, so you can easily looks for post interested you from Chatter Bookmarked menu.


Reference:

Last update: 14 Feb 2017



Sunday, June 2, 2013

Salesforce: Hyperlink in Excel file

Out-of-the-box, a lookup field in Salesforce report is click-able, such as: you can click Account Name in Opportunity report, it will bring user to Account page layout.

But, when the report export into Excel file, the link is gone. Can we make the link stay? Yes, here we go:

1. Create a Formula Field
  • Set the formula field return type = Text
  • Formula field: HYPERLINK("https://xxx.salesforce.com/"& Id , "Click me", "_self") - change xxx with your Salesforce instance, e.g.: ap1, na1, na6, etc
  • Do not need to show this formula field in any page layout
  • Make the field visible only to profile needed.

2. Add Formula Field into Report

3. Printable View
Instead of using 'Export Details' button, advise user to use 'Printable View' button. User can delete the header and footer is not needed in Ms Excel.

This may be not the best solution, but it works with simplest effort.

Salesforce report:


Microsoft Excel:



Salesforce: Using Permission Set to Query User Permission

Permission Set is a powerful feature in Salesforce. If you are using Enterprise and Unlimited editions (including Developer edition). Using the permission set, the admin can assign additional permissions to users on top of the permission given in the Profile assigned to that user. Permission Set is set per user basis and is only to ADD more permissions, not to reduce it from Profile. Permission Set also may be given to admin users when the permission cannot be enabled in the standard System Administrator profile.

Permission Sets include settings for:
- Assigned Apps
- Assigned Connected Apps
- Object Settings, which include objects, fields, and tab availability
- App Permissions
- Apex Class Access
- Visualforce Page Access
- External Data Source Access
- Named Credential Access
- Data Category Visibility
- Custom Permissions
- System Permissions
- Service Providers

In this blog, I am not going to explain how to set up the Permission Set; you can find the overview here.

As of now, we still cannot run a report on the Permission Set and Users assignment to Permission Set. But, since the Summer '11 release (API version 22), Salesforce has introduced 2 new objects related to this: PermissionSet and PermissionSetAssignment. To make this object more powerful, in the Spring '12 release (API version 24), FieldPermissions and ObjectPermissions objects are introduced with ParentId, which points to PermissionSet.

Once you understand the architecture, you can answer all sorts of questions about your users and permission. Here is the diagram (right-click the image to see it in full size) :



Here are a few samples using SOQL to query permission set:

List all Permission Set
SELECT Id, Name FROM PermissionSet 
WHERE IsOwnedByProfile = False 
ORDER BY Name

List all Permission Set that grant extra Permission, such as Create Dashboard
SELECT Id, Label FROM PermissionSet 
WHERE IsOwnedByProfile = False AND PermissionsCreateCustomizeDashboards = True 
ORDER BY Name



List all Permission Set does not from Managed Package
SELECT Id, Name FROM PermissionSet 
WHERE IsOwnedByProfile = False AND NamespacePrefix = '' 
ORDER BY Name


List all Users with ViewAllData Permission
SELECT Id, AssigneeId, Assignee.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE PermissionSet.PermissionsViewAllData = True
ORDER BY PermissionSet.IsOwnedByProfile DESC, Assignee.Name

This query will return all Users with Permission to View All Data, either acquired from the Profile or from the Permission Set.



Compare this with the query below, where it just returns the permission from Profile only.
SELECT Id, Name FROM User
WHERE ProfileId IN (SELECT Id FROM Profile
                    WHERE PermissionsViewAllData = True)
ORDER BY Name


List all Active Users without ViewAllData Permission
SELECT Id, Name FROM User 
WHERE Id NOT IN (SELECT AssigneeId FROM PermissionSetAssignment 
                 WHERE PermissionSet.PermissionsViewAllData =  
                 True) 
      AND IsActive = True
ORDER BY Name 

So instead of pulling all users and all users with specific permission, then doing a vlookup() in Excel, we can combine the query using anti-joint query NOT IN.
Id in the main query is the same ID as AssigneeId in the sub-query, which is User Id.


List all Active Users with Transfer Record Permission
SELECT Id, AssigneeId, Assignee.Name, Assignee.Profile.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment
WHERE PermissionSet.PermissionsTransferAnyEntity = True AND Assignee.IsActive = True
ORDER BY PermissionSet.IsOwnedByProfile DESC, Assignee.Name



List all Users by specific Profile and return the Permission Set assigned to that user
SELECT p.Id, p.Assignee.Name, p.Assignee.Profile.Name, p.PermissionSet.Label FROM PermissionSetAssignment p
WHERE p.PermissionSet.IsOwnedByProfile = False AND p.Assignee.Profile.Name = 'Sales Reps'
ORDER BY p.PermissionSet.Label, p.Assignee.Name

This query will return all Users with Permission Set assigned to users with Profile = Sales Reps and the additional Permission Set name assigned.



List Profile and Permission Set have read access to the Account for a User
SELECT Assignee.Name, PermissionSet.isOwnedByProfile, PermissionSet.Profile.Name, PermissionSet.Label FROM PermissionSetAssignment
WHERE PermissionSetId IN 
    (SELECT ParentId FROM ObjectPermissions 
     WHERE SObjectType = 'Account' AND PermissionsRead = True)
    AND Assignee.Name = 'Johan Yu'
ORDER BY PermissionSet.Profile.Name, PermissionSet.Label

This query will return Permission Set (and Profile if exists) that gives the user read access to the Account object.


List Profile and Permission Set that give Edit access to a Field for a User
SELECT Id, IsActive, ExpirationDate, AssigneeId, Assignee.Name, Assignee.IsActive, PermissionSetId, PermissionSet.Name,  PermissionSet.IsOwnedByProfile, PermissionSet.Profile.Name FROM PermissionSetAssignment 
WHERE PermissionSetId IN 
       (SELECT ParentId FROM FieldPermissions
        WHERE Field='A__c.Support_Staff__c' 
        AND PermissionsEdit = True)
AND Assignee.Name = 'Maria Ann'


List Permission a User has for Account and which permissions give that access
SELECT Id, SObjectType, Parent.Label, Parent.IsOwnedByProfile, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords
FROM ObjectPermissions
WHERE (ParentId IN (SELECT PermissionSetId FROM PermissionSetAssignment WHERE Assignee.Name = 'Johan Yu'))
AND (SobjectType = 'Account')
ORDER BY Parent.IsOwnedByProfile DESC, Parent.Label

This query will return user permission for an object and also tell all Permission Sets (and profiles if they exist) that give the user that permission.


Show Object Settings added to all Permission Set
SELECT SobjectType, Parent.Name, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords FROM ObjectPermissions WHERE SObjectType IN ('Account') AND Parent.IsOwnedByProfile = false

This query will return only Permission Set with additional permissions on a specific object.


Get all Non-Chatter users with Lightning Experience permission enabled
SELECT Id, Assignee.Username, Assignee.Profile.Name FROM PermissionSetAssignment WHERE Permissionset.PermissionsLightningExperienceUser = True AND Assignee.Isactive = True AND (NOT Assignee.Profile.Name LIKE '%chatter%') ORDER BY Assignee.Username


Mass Assign Permission Sets to Users
Based on PermissionSetAssignment attributes, we can use Data Loader to mass assign (and mass delete) users with a specific Permission Set. All you need to provide is AssigneeId (which is User Id) and PermissionSetId. But, you cannot update the record in PermissionSetAssignment.



Reference:


Last update: 9 Jul 2024


Page-level ad