Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

st Just because you are not a Developer does not mean you can't use great developer tools to get more stuff done in Salesforce. This is how I use MavensMate and Git for configuration and backup of Salesforce - and I'm not a developer. 

Table of Contents
maxLevel3

What you can do

  • Download your Salesforce Configuration
  • Search through your Salesforce Configuration - where is x Field or Label used. 
  • Create new Fields
  • Update Fields (minor changes such as label, field lengths, etc)
  • Change the ReferenceTo (eg from Account to Contact) for a field
  • Changed a field type (eg from currency to number). (Some conversions are not possible).
  • Add Picklist Values
  • Backup your Salesforce
  • See what is changed in your configuration
  • Put things back if you accidentally delete them 
  • Duplicate Page Layouts
  • Duplicate Views
  • Duplicate Reports
  • Deactivate Triggers on Prod

What you can't do

 

Info

You can do these things using Eclipse, but I just like Maven's Mate, so that is what this article focuses on.

Warning
titleEnterprise Edition Only

These features will only be possible in the Enterprise (or Developer etc) editions. "creating a custom field dynamically is not possible in GE/PE even with the API Token" from http://www.salesforce.com/us/developer/docs/packagingGuide/Content/dev_packages_api_access.htm

Tools

See Installing the

Tools

below for more tips. 

Note

All these tools are available on Mac and Windows - the screen shots and steps below are from Mac and may be different to Windows

About the Tools

A note about Git

Git is a bit different than Github. Git is very techy and is usually used from the command line by issuing text commands. I use SourceTree because it is not very techy and is not that much different than using a simple text diff tool, and a backup tool (well the way I use it anyway). I know that I could learn much more and use git and SourceTree in a much better way, but for the purposes of this article you really don't need to know much about git... we are just using SourceTree and BitBucket to save your Salesforce Configuration.

You will still want to have a Github account (yes, I have one), even if it is only to make bug submissions or share Gists. (Gists are pretty cool, and they can even be secret - well not show up in the main Github search, anyway). 

In this article I am not covering anything about branches and pull requests and merging. You can delve into that in your own time - and it may be useful if you work with a team. There are a few great git tutorials eg https://www.atlassian.com/git/tutorial and and http://try.github.com/ and http://pcottle.github.io/learnGitBranching/. For our purposes in this article, commit is the same as backup (smile)

Sublime Text

Yep, Sublime Text is just a text editor, but it is pretty cool at being just a text editor. It costs US$70 and whilst you can use it with "buy me" prompts, it is worth buying if you use it a lot. There is SO MUCH I don't know about using Submlime Text it is not funny. But every time you use it, you will learn a few things more. 

MavensMate

You might think that Sublime Text is a plugin for MavensMate, but it's the other way around. MavensMate is a plugin for Sublime Text. MavensMate is a really cool tool that uses the Salesforce Metadata and Tooling APIs to modify your Salesforce configuration. It does similar things to Eclipse, but in a much more elegant and quicker way. MavensMate has a new version and these notes are for the original versions of MavensMate, with some adjustments for the new version, which are noted. 

Note. When MavensMate installs a new version it seems to keep the old version installed, so go and uninstall the old version when you are happy with it. 

BitBucket

Bitbucket is a tool that can host git repositories. Really the only thing you need to know about it right now is that it is similar to Github in many ways, but it has free private repositories. That means you can store your Salesforce configuration in the cloud and it is password protected. If it's on github it's going to be visible to the world, and that may not be good for your organisation. You can pay US$7/month and get private repositories on Github and do similar things - the choice is yours. Bitbucket is made by the Australian founded company, Atlassian, who also make Confluence, the fabulous tool you are reading this article on right now. Oh, and the other cool thing you can do with Bitbucket is sharing - so if you have a few in your team, you can share your repositories. 

SourceTree

SourceTree is another app by Atlassian. Yep, I know I could get really techy and use Git via the command line, but hey, we are not devs here, and we just want to do things simply, so Source Tree is a great tool to do this job. 

Note: the latest version of Source Tree for windows has a known bug. Please download the older version.  

Installing SourceTree will also install Git - just use the embedded Git unless you really want to get techy. It's OK to then say you don't want to use Mercurial. 

When installing SourceTree just use Putty PuTTY unless you have a particular need/want to go down the Open SSH route (eg you have an IT person saying it's the only way to go). Say No and create an SSH key later. 

Other cool tools

See Useful Google Chrome Extensions for Salesforce for more details. 

Installing the Tools

I haven't covered installing all the tools on this article. I do remember it was a bit of a pain to get it all working well. If I ever have to install them again, I will update this article. 

Info

OK, just tried to help a friend install this from a previous installation and it was difficult!!! This article helped http://mavensmate.com/Upgrade_Help.

Tips

  • Uninstall everything.
  • Install ST and MMApp then do the package control thing (below).
  • Then do the path settings in Mavens Mate Settings.
  • Then close sublime text and MMApp
  • Then Open ST
  • Then Open MMApp
  • Then try creating a new Project from the MavensMate menu in ST.
I'm getting a new PC soon so I will try this again on a clean install.

As the following article suggests - use Sublime Text Package Control to install it. http://mavensmate.com/Plugins/Sublime_Text/Installation

Creating the Project

Open ST. Use the MM menu to create New Project. For the new MavensMate App the App has to be open first before you can use the Project menu. It is really kind of annoying. I did like the old way it worked. 

(note: I do have a licence for ST, I just haven't registered it on this machine yet). 

Note
titleKeyboard Commands

There are a lot of keyboard shortcut commands for Sublime Text, but as we are probably more familiar with menus and clicks (clicks, not code), I will show all the menu based commands, but see http://mavensmate.com/Plugins/Sublime_Text/Shortcuts for shortcuts.

Login

Enter the Name of the Project, your User Name and the Password+Token - chose Production or Sandbox. Go to the Advanced Tab. 

The location will default to the location you set up in your settings file (mm_workspace http://mavensmate.com/Plugins/Plugin_Settings). 

After you click the Advanced Tab or click Create Project, MM will log you into SF. 

After you click Create Project, it will take a bit of time to download all the metadata and create the project in ST. 

Advanced

Note: the screenshots here show Update Project for an existing project - the options are the same for a new project - you just have a Create Project button. 

This is where you choose what metadata to sync. It is easy to just choose everything, but it will dramatically slow your syncing down. 

In this list, you can't select ALL options at once - you have to click 51 times - probably to make you avoid clicking every single one of them. 

The default is 7 items selected, but you can change the settings file with mm_default_subscription. See SubscriptionSettings.txt for a list of the (current) 51 items. 

This screen is a little tricky - click on the drop down list again to hide the list of options and reveal the rest of the form. 

Remember to click Update Subscription when you are done - not to be confused with Update Project. 

If the Refresh Index button is displayed, click that also (and wait). You will hear the nice MM "ding" when it's done. 

Project Metadata

On this list you can chose all at once. 

Check the unlabeled grey checkbox 

Click Update Project when finished. The "ding" will sound when it's done. 

Info
titleManaged Packages

Objects, Page Layouts etc from Managed Packages (Apps from the App Exchange or maybe from a Developer you are working with), will NOT be in this list. You have to manually add the names to the package.xml file. See http://salesforce.stackexchange.com/questions/13852/how-to-retrieve-layouts-of-customs-objects-belonging-to-a-managed-package for more info.

 Example:

Code Block
    <types>
        <members>Account</members>
		<!-- Excluded for brevity -->
        <members>Task</members>
        <members>User</members>
		<!-- Added the Payment Txn Object from the AAkonsult Payments App -->
        <members>AAkPay__Payment_Txn__c</members>
        <name>CustomObject</name>
    </types>

 

 

When the Project is Setup

What do you get

The config folder

Hopefully you won't need to delve into here too much if you are not a developer. 

The src folder

The src folder contains all the Salesforce configurations "source" - the metadata (or structure) of your whole Salesforce org

The files are in generally XML format, except for the code files (triggers, classes). 

If you ever need to understand anything about the metadata, check the Developer Reference http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_types_list.htm

Key Files

Objects

Eg Account.object

Each Standard and Custom Object in your Org is has a file. It may look a bit daunting but use your search (ctrl+f) to find a field name that you know, and then work back from there. 

See Object Metadata

Layouts

Each Layout has it's own file. 

When you have a number of Rules for Page Layouts the only real way to keep them up to date easily is through the metadata API. 

See Layout Metadata

Reports

Quickly modify or duplicate reports with different parameters

Emails

Quickly modify some text - especially if multiple emails are affected. 

Permissions

Search the permission in each Profile

Actions

You can't duplicate Actions via Setup - you can here! 

Report Types

Using your fields exported from the List Fields for Object command, modify the text to quickly add all the new fields to the Report Type

Workflows

Quickly duplicate workflows with different conditions. 

Find where a field is used in the workflow. 

Modify conditions. 

Backup the Project to the Cloud

Open SourceTree

Create the repository

  • Click the Add a Repository button (the first one). 

  • Click Create Repository
  • Select the folder you saved your MM files in. 
  • Give it a name
  • Click Create

Open your Repository

  • Select all the files in the working tree (click on one then do ctrl+a/cmd+a)
  • Drag the files to the staging index

Add a remote repository in BitBucket

  • Right Click on REMOTES
  • Click New Remote...

  • Click on the World Icon

  • Connect to your Bitbucket
  • Enter a Name
  • UNCHECK Publicly Visible. 
  • Choose Git as the type. 
  • Click Create Repository
  • Choose that new Repository in the list of Repositories available. 
  • Click OK

  • Give the remote a name. Click OK

Commit

  • Click Commit

  • Enter a Commit Message - just a note to yourself to say why you are saving your Salesforce Configuration at this stage. I normally do this before I do major changes to the configuration. 
  • Check Push commits immediately to (and select your Remote). 
  • Click Commit

It's done - your Salesforce Metadata is now backed up to the cloud. 

Using MavensMate

Triggers and Classes

If you are in Sandbox you can modify Triggers and Classes. If you are in Production, you can look at the code, and you can set triggers to be inactive, but you can't modify it. 

One good thing about looking at code through ST is the colours!

Code comes in pretty colours (yes, it is blurred out). 

Metadata

Use the List Fields for Object command to list the fields in a selected object - helpful for pasting into any documentation you may be doing.  

It's a simple list, and I think that Grey Tab provides a better way of accessing this information, but it might be helpful. 

Use regular Search (Cmd+F/Ctrl+F) or Search in Folder (right click on src and chose Search in Folder)

What to search for

  • Field Name
  • Field Help Text
  • A specific formula (eg "*1.1" to find GST to change it when the horrible Liberal government ups the rate - not that your GST rates are hard coded - are they?!?!). 

Refresh the Org in ST

  • Open the MM Project in ST
  • Right click on src, chose MavensMate, then Refresh from Server...

  • The refresh will start

  • The updates will show in the bottom of the ST window. 
  • Remember to then check in your latest updates to BB to save them. 

Create Fields

Using Excel to create the XML Structure for new fields https://success.salesforce.com/answers?id=90630000000gtheAAA

Here is the template that I use https://docs.google.com/spreadsheet/ccc?key=0Ar3Bg2QuV-_IdEtzSXBrWTZiNUZxRlRoV0tYM3RoZ2c&usp=sharing thanks to Ezra Kenigsberg - Make sure you read the notes and save this as a copy for yourself. I have modified the file to include Help Text and basic security - feel free to build on anything that I have done and let me know so that we can share it here https://docs.google.com/spreadsheet/ccc?key=0ArmEWnxyp7DvdDFpX0c2LWh4UDBlUzZtZW9wOUVUcUE&usp=sharing

Update Fields

  • Update the Help Text
  • Create new Picklist Values (although it is probably easier to do this via the UI). 

Issues and Gotchas

  • it uses Token Authentication, which is a real pain when your passwords change and you have to enter the username, password and token again. (Dataloader.io is fabulous for using OAuth now, and it's the way all dev tools should work). 
  • Name your projects really really well. (Well that might not be an issue if you just have Live and Sandbox, but for me who has multiple projects, it gets annoying if I'm not careful). 
    • Go to Config>.settings to see the details of the project if you get a bit lost. 
  • Everything takes a little time, so be patient with it. 
  • You are going to get stuck on the settings of what items have been synced - if you can't see everything, then go back and check those. 
  • Both Sublime Text and MavensMate are updated so regularly that if you are not using them every day, you probably have to install an update before you can use them. So just give yourself some time. 
  • You have to go through a specific routine to update the plugin. 
    • Close ST
    • Download MM
    • Run MM
    • In MM Menu chose to update the ST plugin. 
    • Run ST

Further Reading

This approach uses the Metadata API or the Tooling API, so it might be handy to get to know the Salesforce API's. See Salesforce API. Also try to understand more about Salesforce's Metadata in general. 

Filter by label (Content by label)
showLabelsfalse
spacesSF
showSpacefalse
cqllabel = "tools" and space = "SF"
labelstools

Further things to look into

  • Use unmanaged packages to deploy to Salesforce. See Deployment.
  • Save your configurations into an unmanaged package to deploy to other orgs.
  • Using Ant.  
  • Get to know Resource Bundles in MavensMate. (see articles above). 

  • Get to know a lot more of the shortcuts and customisations in MavensMate. 

  • Command Line Git
  • Git version control built right into MavensMate

If you are a dev and are reading this

You may want to take things way further...