Pages

Thursday, August 21, 2014

How to use Salesforce sharing rules with Profiles?

Scenario: we have a group of people need to edit all opportunity, this user is defined by Profile. When we enable Modify All permission in the profile, it will enable Delete permission as well, which is not allowed. User in the profiles scattered around many Roles.

Thinking about to use sharing rules, but as of know Summer '14 release, sharing rules is based on Public Group and Role only. To create a new Public Group and add user to the group manually is not nice solution as admins tend to forget to add / remove user from the group.



To move all users from those Profiles to top role hierarchy is not good option, as it will open access to all other objects.

Found an idea in IdeaExchange - Sharing Settings allow Share With User or Profile

Since all point and click option is not a good option. We found it is easier to use a simple trigger to block user to delete the record.
  • Left Modify All permission enable for the Profile (which also mean Delete permission enabled)
  • Add a trigger to check what is the User Profile
  • If the Profile(s) allowed to delete might change, you can use a Custom Setting to specify the Profiles allowed, and have the trigger read the Custom Setting instead of hard coding.
Here is a snippet of the trigger for Opportunity, where you can enhance with multiple Profiles and Custom Setting

trigger StopDeleteOpportunity on Opportunity (before delete) {
    for (Opportunity opty : System.Trigger.Old) {
        String profileId = userinfo.getProfileId();
        System.Debug('userinfo.getProfileId - ' + profileId);
        String profileName=[Select Id,Name from Profile where Id=:profileId].Name;    
        System.Debug('Profile Name - ' + profileName);

        if (profileName != 'Sales Ops')
        {
            opty.addError('You are not allowed to delete Opportunity',False);
        }
    }
}


Reference:

Monday, August 18, 2014

Salesforce #Cleanup with Field Trip

This would be my 3rd blog of AppExchange product, after: DupeCatcher, Enabler for Excel part 1 and part 2. Over years when consultant comes and go, new admin on-board and leave - many enterprises do not even know what is the purpose of custom objects and custom fields created in their org, would it be just used as reference table or something else needed at other app.

Take a Field Trip! This utility lets you analyze the fields of any object, including what percentage of the records (or a subset of your records) have that field populated. Get it for free from AppExchange.

Let me show how easy to use this tool:

1. Install from AppExchange
Follow above linked to install in a sandbox or production instance. Once installation done, you should see it in Installed Packages, from SetupInstalled Packages



2. Field Trip Tab
Click '+' tab (or URL https://xyz.salesforce.com/home/showAllTabs.jsp - change xyz to your Salesforce instance) to show All available tab and look for Field Trip tab


3. New Field Trip
Click New Field Trip button to start analyze.


Enter a Name, select the Object, and optional for criteria if you do not wish to analyze not whole records for that object. Click Save button when done.



4. Analyze It !
Click Analyze button then Begin Analysis in the next screen. It may take a while for Field Trip to get the data.

You can monitor the progress from Apex Jobs (Setup | Jobs | Apex Jobs). Once done, you should get email with subject "Field Trip Processing Complete: field trip name" which contain a URL link to the to see the analyses result. The status in the Apex Jobs also will update to Completed, looks for with Apex Class = analyzeObject


5. Report It !
Create new report with report type Field Trip with Field Analyses


Add filter to the report with Field Trip: Field Trip Name equals Singapore Account (this is field trip name - see step 3 above for my sample)
You can use standard report feature such as bucket field to make it easier to read for a high level result.


If you see sample above, we have 269 fields in Account object, 103 fields of them for Singapore Account do not have any value populated, 49 fields have only 0-5% value populated. We can easily see from the report that more than 50% of field is not really used, which mean it may good to remove.

Note: if you have ETL or other SOAP API tool accessing your data with fix fields in query, you need to check with integration team, otherwise it will break the integration. Another tip, before hard delete the field, you can just remove visibility permission from field level security to all profiles.


Reference:


Sunday, August 17, 2014

What is my Salesforce Edition, Instance and Release ?

Edition
When you are going to implement Salesforce.com for your company's CRM system, which editions should I purchase? Salesforce.com come with a few editions, the higher edition has more features, is more expensive, and has fewer limitations, here is a list of features in comparison, and here list of limit.

Remember you can upgrade from one edition to a 'higher' edition using the same instance, but not downgrade, for some reason when you opt to downgrade, Salesforce will provide you new instance and you need to manually migrate all configuration and data, which is very troublesome.

List of editions in order (from lowest to highest):
  • Contact Manager 
  • Group
  • Professional
  • Enterprise (include Developer)
  • Unlimited (not available for a new purchase)
  • Performance 

How to check my Salesforce Edition?
There are a few ways to do this:

1. Hover your mouse over the web browser
Once you have a login to Salesforce, hover your mouse over the web browser tab.

Google Chrome

Mozilla Firefox

Internet Explorer

Opera


2. Go to Setup - Administer



3. SOQL
For developer: SELECT OrganizationType FROM Organization




How to check my Salesforce Instance?

1. URL

In the screenshot above, this is a CS3 instance, which is a sandbox. Sandbox instances always start with CS, while production instance for America instances starts with NA, APAC instances start with AP, and EMEA instances start with EU. Click here to see all instances including system status.

For those who are not familiar with Sandbox, an instance of the salesforce.com service that hosts full copies of production orgs for customer application development purposes. Customers using our platform can have full application development lifecycles. These are test environments for customers to do user acceptance testing against their applications before deploying changes into their production org.

If you are using the My Domain feature, check here to get the instance name.


2. SQOL
For developer: SELECT Id, Name, InstanceName, IsSandbox FROM Organization




How to check my Salesforce Release?

Since Salesforce.com is on cloud and sharing infrastructure with customers using Salesforce, users in the same instance will run the same version/release. See his blog for more information on sandbox - Salesforce Release and Sandbox

To check which release in your sandbox or production instance:

1. Logo
Check the logo at the top left, make sure it is not a custom app, for example Sales app.



2. Discover button
Go to the Home tab and look for the Discover button





Reference:


Thursday, August 14, 2014

Who is "Grant access to admins only" when install AppExchange?

AppExchange is like App Store for Salesforce.com, where Salesforce admin can install apps suit to their needs by point and click only, the same experience as you configure Salesforce.com. Some of them are paid and many are free.

If you have sandbox instance, it is strongly advised for admin to install it in sandbox before install in Production. Admin and user can fully test the app in sandbox before go for Production. Although, you always can uninstall it.

Once you enter your Salesforce login credential, in Step 2. Choose security level. There is option who should able to access the package, this is very good to minimize impact when not all users need to access this package.


If you select the first option Grant access to admins only, what does this mean, who is admin actually? It mean users with profile Customize Application permission enabled.

What will the installation package do:
  • Object permissions—“Read,” “Create,” “Edit,” “Delete,” “View All,” and “Modify All” enabled
  • Field-level security—set to visible and editable for all fields
  • Apex classes—enabled
  • Visualforce pages—enabled
  • App settings—enabled
  • Tab settings—determined by the package creator
  • Page layout settings—determined by the package creator
  • Record Type settings—determined by the package creator

License
Selection in installation process do not impacts to app licenses (for not free app). If the app is licensed at user level (not org-wide license), you’ll need to add licenses manually for each users from Setup | Installed Packages | app name | Manage Licenses. This is important, because even if you pick Grant Access to All Users, users will still need to have a license to the app in order to be able to see any of its components. Exception for Sandbox instance, add license activity is not needed.


ReferenceInstall a Package



Wednesday, August 13, 2014

Ten things you need to know about Activity in Salesforce



1. Activity contains Event and Task, they are stored as two separate objects, but you can run report as Activity which contain data from both object.

2. Completed Task will move from Open Activities to Activity History in page layout related list, the same for Event when Due Date is over.

3. By default, there is no Task or Event tab - Activities Tab and View (Event or Task)

4. Activities archive over one year - Archived Activities

5. Not possible to create custom lookup field on Activity (delivered in Winter '16)

6. Cannot assigned to a Queue ; vote for this idea Allow Task(s) to be assigned to a Queue

7. Sharing setting only Controlled By Parent or Private

8. There is no option to create workflow with email alert action - No Email Alert action for Task & Event Workflow ; vote for this idea Email Alerts for Activity Workflows

9. Workflow with field update action on Task cannot update some standard Task fields, like: Due Date, Name, Related To

10. You can create Task from workflow, but it only will have one: Name (Who) or Related To (What), it depends on the Task action related to which object.


Monday, August 11, 2014

Salesforce: Merge Field for User Object in Email Template

Email Alert in Workflow in Salesforce.com is simply awesome and easy to configure. The feature has been available since long time back. This blog is not going to discuss how to create Email Alert for Workflow, but you can read it through this documentation.

To make the email more meaningful, admin can add merge fields into the email subject or body. Rather than a static email "A case has been created", it is much meaningful to have email with message "A High priority case has been created - No: 001001" and email body contain more information, such as: Subject, Type, Priority, etc.

Admin just need to create an Email Template with merge fields from any object, from: Contact, Lead, including custom objects. Read this documentation.

Use Case: send email alert to a public group when a Salesforce user (not Chatter only user) has been deactivated.

1. Create Email Template
Subject: {!User.Region__c} Salesforce user has been deactivated - {!User.Name}
Body:
Hello,

Please note following user has been deactivated:
Name: {!User.Name}
Username - Region: {!User.Username} - {!User.Region__c}

Link: {!User.Link}

regards,
Salesforce.com


2. Create Email Alert
Make sure to select Public Group as Recipients and correct Email Template.


3. Create Worklow
Object = User
Evaluation Criteria = Evaluate the rule when a record is created, and every time it’s edited
Rule Criteria =
TEXT(UserType) = "Standard" && 
IsActive = False &&
PRIORVALUE(IsActive) = True

Add Email Alert above as immediate workflow actions and DONE!

But, wait a minute... something wrong with user information in the email received, merge field in email template have information of the user who has actually deactivate the user i.e. system admin and NOT the user which has been deactivated.

Good news in Summer '14 release, Salesforce introduce Workflow Target User Merge Fields for Email Templates, by changing merge field from !User to !Target_User, simply modified above email template:

Subject: {!Target_User.Region__c} Salesforce user has been deactivated - {!Target_User.Name}
Body:
Hello,

Please note user following user has been deactivate:
Name: {!Target_User.Name}
Username: {!Target_User.Username} - {!Target_User.Region__c}

Link: {!Target_User.Link__c}

regards,
Salesforce.com

If you notice last merge field above for link {!Target_User.Link__c}, it is a custom field, just change it to to {!Target_User.Link} will not work. Further search and test found that


This maybe a defect as currently it still Beta. So, the workaround, I create custom formula field in user object "https://xyz.salesforce.com/" & Id & "?noredirect=1" (change xyz to your Salesforce instance) - done !!


Reference:

Page-level ad