Pages

Wednesday, December 16, 2015

Salesforce: Getting Started with Objects related to Salesforce Product

Product is not new features in Salesforce, it has been there for long time and widely used. I see many companies using Sales Cloud, but not use Product. In this blog, I would like to introduce how Product work in Salesforce, from the basic.

1. You can rename it
Some company do not like it called as Product, because not suit to the business terms for the company. As admin or consultant, you can rename it as Service, or Opportunity Line.
  • Go to Setup - CustomizeTab Names and Labels Rename Tabs and Labels
  • Looks for Products and click Edit link prior to it.
  • You need to enter Singular and Plural name, in this blog, I'll use Opportunity Line
  • Click Save to finish, or Next if you would like to change field label related to Product, by default all "Product" field labels has been rename to "Opportunity Line" for Standard and Other field related to Product.

This will change all label in Salesforce user interface from Product to Opportunity Line, from: Related List name, Tab name, Report Type name, Field name in report, and etc, except the one related with API name and not visible by end user directly, such as: Workflow, Validation Rule, and so on.

Sample of the change happened in related list in Opportunity page layout.
Before:

After:


2. Product is a special object
  • It is not the same with other standard object or custom object, Product is linked to Opportunity and Quote through Price Book.
  • Each Product added into Opportunity in an object called Opportunity Product, so this object would be a junction object. For Product added into Quote called Quote Line Items.
  • You can create roll-up summary field from Opportunity Product to Opportunity, and from Quote Line Items to Quote.

3. Product Object
  • The API name is called as Product2, with object prefix 01t
  • To directly access Products tab from Salesforce user interface, go to https://na3.salesforce.com/01t ; change na3 to your Salesforce instance. 

4. Price Book Object
  • You can have multiple price books in Salesforce, each price book may contain different Product and can have different List Price.
Example: a product available in EMEA price book may not available in APAC price book, but available in AMER price book. However, the List Price for AMER price book can be different with EMEA price book.
  • The API name is Pricebook2, with object prefix 01s
  • User with read access to Product and Price Book, user can access Price Book from Price Books tab or directly go to https://na3.salesforce.com/01s ; change na3 to your Salesforce instance. 
  • Each Opportunity or Quote only link to single Price Book. 
  • If there is only a single price book is active, or the user only has Use permission to a one price book, then that price book is automatically selected when user adding products to Quote or Opportunity.
  • If user has Use access to more than one active price book, user must manually select a Price Book prior to adding products to Opportunity or Quote.
  • If user has Use access to more than one active price book, user able to change selected Price Book for the Opportunity or Quote, but all Products added will be removed.




Reference:


Monday, December 14, 2015

Install MavensMate for Salesforce Admin

When you read this blog, MavensMate creator has decided to end development and support of MavensMate, but that does not mean we cannot use MavensMate anymore.

Force.com IDE - a powerful client application for creating, modifying and deploying Force.com applications. But for some people, like my case, the IDE not really working smoothly with my office machine which is still with Windows 7 32-bit. In many times (often), it just hangs when try to select more components to the project. Some other users said that Force.IDE is so clunky and finicky. The other user looks for faster IDE at getting metadata and more user-friendly. Eclipse is slow to load and tends to get heap size limits with an org of bigger metadata size.

Recently I found another Open Source IDE for Salesforce.com (it is free), it called MavensMate. As in their website now - it works with OSX (10.8+), Windows (Server 2008, Windows 7, Windows 8), and Linux (Ubuntu 14). Although it doesn't say Windows 10, I just try and it works well.

I read a blog say MavensMate installation for OSX is a breeze, but not for the Windows machine. I found myself takes sometimes to get this installed, the installation guide from the website is not really detail - MavensMate Getting Started.

Before I explain step by step to install MavensMate, for Salesforce Admin, IDE is not always just for developers, although it is mostly designed for that purpose. Example, with IDE you can easily search where a field used in the reports (of course not include reports in user personal folders).

1. Download Sublime Text
Use only version 3 (or above), download from here.

2. Install Package Control
Once you have Sublime Text installed successfully, go to this link to copy Python code to install Package Control to Sublime Text console.
From Sublime Text, open the console via the ctrl+` shortcut or the View > Show Console menu. Paste the Python code copied earlier and press enter, this will install Package Control. Monitor the console log until installation finish, this process should be very fast - less than 1 minute in my case.



3. Restart Sublime Text
You will need to close and open Sublime Text manually to finish Package Control installation.

4. Install MavensMate
- Open Package Control with Ctrl + Shift + P and type install 
- Select the Package Control : Install Package


- Type mavensmate and press enter 

5. Download and install Mavensmate Desktop
Because of MavensMate is no longer develop and support, you can download MavensMate Desktop from Github. There is an option for portable installation too, so you just run the MavensMate.exe file when need it.


6. Setting Workspace
Now, MavensMate is installed in your Sublime Text. Next, you need to set the workspace for the user in MavensMate. From MavensMate Desktop, select Settings, you can set the path where you want to store all files related to MavensMate project.


Make sure the path is valid and the user has full access to the path entered as a workspace.

6. New MavensMate project
From menu MavensMate | Project | New Project... system, for an unknown reason, the system may ask you to update MavensMate, navigate to  MavensMate | MavensMate API (mm) | Update MavensMate API (mm). You need to close and open Sublime Text again.
Once this done, click new project again and it should open a web browser to enter Project name and login credential, you may need to click Advanced and Project Metadata tab to make sure all metadata you need is selected.




Based on Metadata selected upon project creation page, the metadata will be shown at the left side.



You also can Edit Project to add/remove metadata selection for the project.



From here, if you would like to search for something, example: a field name, right click on project name or Ctrl + Shift + F to open search window.



The search result will be shown in the find results, from: apex class, reports, object (including field, validation rule, help text), etc based on selected metadata.




Reference:


Sunday, December 13, 2015

Data.com Prospector: How to Identify?

When you subscribe for Data.com Prospector and Salesforce.com, you can easily add person to Salesforce as Contact or Lead, and company as Account. But, overtime you need to monitor how many person and company has been added, this is also to tell on how optimize users is using Data.com?



For records added from Data.com, you can query or run report on following fields:

Account
  • "Data.com Key" field is not blank, this would be filled with digits

Contact and Lead
  • "Data.com Key" field is not blank, this would be filled with digits
  • "Lead Source" is filled with Jigsaw or Data.com


You also can install a free package from App Exchange Data.com Prospector Reports, this package will add custom report type "Data.com Users and Usage", custom field "Sourced from Data.com" in Account, Contact and Opportunity, a dashboard and reports used as data source for the reports.



Wednesday, December 9, 2015

Salesforce: State and Country Picklists

By default, State and Country is textbox field, where user can enter any data. Some organization hire developer to write trigger to validate the data entered is valid. Another option is to use AppExchange product such as AddressTools Premium or AddressTools Free.

But if you are not aware, Salesforce actually have something called State and Country Picklists, this is out of the box feature to change textbox field to picklist for both State and Country, this is applicable for shipping, billing, mailing, and “other” address fields in standard object:
  • account
  • campaign members
  • contact 
  • contract
  • lead
  • person accounts
  • quotes
  • service contracts 

Benefit
When State and Country Picklists is activated, users will be not able manually to type into State and Country, but they have to select from picklist. This will make your data clean, e.g. United States maybe enter as USA, U.S., United States America, this will make you will be difficult to analyze data correctly.


How to activate this?
1. Navigate to SetupData ManagementState and Country Picklists

2. Click Configure states and countries in step 1
  • You can set default country, in case your business mostly only happened within a country. 
  • By default Salesforce will provide 239 countries and some of them have States/Provinces. For countries that you know should have State, but not available, click Edit link on that country, click New State button to add State. This manual process will take a lot of time when you need to enter many State not available out of the box.
  • You also can modify the Country Name and Integration Name. Integration Name must be unique, Salesforce uses this value to integrate new picklist values with former text-only values. It is not case sensitive. When you add new country, Country Code must be unique and you cannot modify standard country code.
  • To hide a country visible for user to select in picklist, unselect Visible checkbox

3. Click Scan Now in step 2
  • You will receive 2 emails: one regarding affected address data and one regarding affected customizations. 
  • For customizations scan result, you need to download a text file from document, this will include where State and Country used in your org: 
    • Apex Class
    • Visualforce Page
    • Apex Trigger
    • Assignment Rule
    • Auto-Response Rule
    • Email Template
    • Escalation Rule
    • Field Set
    • List View
    • Report
    • Validation Rule
    • Custom Button or Link
    • Workflow Rule
    • Matching Rule
For reports and list views, it will not include reports and list views in personal folder or visible only to a user, except it owned by user who run the scanner.
4. After get two emails above, click Convert Now in step 3
For address (state and country), you need to select the data and select a value from Change To picklist, If you do not know the right value at that moment, you can map it to "Unknown value". Users user open the record, they will see original state and country (not Unknown value), but they will encounter error to save, unless they change the state or country to a valid value before saving. You should only map to "Unknown value" when you do not know the correct value.
This step will take a lot of time to clean up invalid data manually.

5. Once conversion process finish, you will be able to click Enable button at step 4 Turn on state and country picklists.

Notes:
1. If you change a country name at step 1, the original name will be shown in Change To picklist when you convert state or country to picklist, just select the original name, and it will use value renamed, example: Viet Nam to Vietnam. This maybe a Salesforce defect, but not a blocker.



2. Notice two new fields created for all objects with standard address field, which is BillingCountryCode and BillingStateCode.

Before enable state and country picklist:

After enable state and country picklist:



3. From the last screenshot above taken from SOQL query, invalid value converted to 'Unknown value' will not have value in the Code field. For valid values, code will be auto populated with the Country Code and State Code.

4. When we run report, we can see the old value with suffix (text only)



5. When you open existing report with state or country, it will prompt you to update the report with new picklist field.

But, if you do not have permission to edit the report, here is the screenshot.

Effect with Insert / Update (integration or mass loader)
  • So which field should I use? BillingCountry or BillingCountryCode or both? You can provide only one value, either name or code, and the other value will be auto populated by the system. But if you populate both for some reason, make sure the code is align with the country name, otherwise the insert/update process will be failed. The same goes for State.
  • The country / state name or code must be exist in the picklist value defined, otherwise the insert/update process will be failed. 
  • When you insert / update State, make sure that state is available for that particular country, otherwise the process will failed.

So this is how it looks like when you had State and Country Picklists enabled. Notice both Country and State is a picklist, and State picklist value is depend on Country selected.



Reference:

Tuesday, December 8, 2015

Salesforce: Export non-English characters

We wrote a blog sometimes back on how to import data with non-English characters into Salesforce - Mass upload/insert non-English characters to Salesforce. UTF-8 encoding play important role when working with  non-English characters.

Salesforce by default support multi languages, so your user may enter data in their local language. When user run a report, it will show in the correct local language as well.



But, when user click Export Details to export into Excel file, it maybe shown as ???



This may caused by wrong selection of Export File Encoding, to support Non-English characters, make sure to select Unicode (UTF-8) when you export data export into excel.



Screenshot below would be the correct result exported to Excel file.




Sunday, December 6, 2015

Salesforce: Mass Update from List View using JavaScript

Sometimes back, we discussed on how to update Salesforce with JavaScript from a button in a page layout. Next, recently we have issue on how to replicate the same for many records to mass update from list view? Inline Editing in one the option to mass update records from a list view, read this blog for more information on how to use inline editing in list view.

But how about if we always need to mass update with the same data? It can be for only 1 field or for multiple fields, example: update Account type to Customer. Using inline editing may not always be the best option with all the limitations of inline editing.

Solution:
We can use similar approach of using JavaScript to mass update many records from list view.
1. Create custom button with Java Script
2. Add the button to list view

For this blog, we will use scenario to mass update Account type to Customer.

1. Create custom button
  • Navigate to Setup | Customize | AccountsButtons, Links, and Actions
  • Click New Button or Link
  • Enter Label, select Display Type = List Button and enable Display Checkboxes (for Multi-Record Selection), Behavior = Execute JavaScript, Content Source = OnClick JavaScript
  • Copy and paste following script
 {!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")}  
 var records = {!GETRECORDIDS($ObjectType.Account)};   
 var updateRecords = [];   
 if (records[0] == null)   
 {   
  alert("Please select at least one Account")   
 }   
 else   
 {   
  for (var i=0; i<records.length; i++)   
  {   
   var acc = new sforce.SObject("Account");   
   acc.id = records[i];   
   acc.Type = "Customer";   
   updateRecords.push(acc);   
  }   
  result = sforce.connection.update(updateRecords);   
  window.location.href = "/001";   
 }  




2. Add the button to list view
  • Navigate to Setup | Customize | Accounts | Search Layouts
  • Click Edit on Accounts List View
  • Select the custom button created and move it to the right on Selected Buttons
  • Save and done



Note: if the record unable to save for some reasons, maybe validation rule, the error message will NOT display and user may not aware. But, admin can debug this with Debug Log.


This operation will consider as "Api" with Application pointing to the custom button id.



Page-level ad