Use SalesforceXytoolsForSublime to develop SFDC

Posted by ExiaHuang on October 27, 2018

Topic

  1. create/update/delete/refresh local file : ApexClass, ApexTrigger, ApexPage, ApexComponent
  2. Diff between localhost and server
  3. Open metadata in sfdc
  4. Deploy : ApexClass, ApexTrigger, ApexPage, ApexComponent, Lightning
  5. Run Test Class

Environment

  • Make sure you can login your sfdc. Test it : SFDC-XY > Login SFDC

Start Develope

Create ApexClass

This is an example of batch apexclass.

Step1. New ApexClass

Metadata > New ApexClass

1540364550961

Tips : Create ApexClass, ApexTrigger, ApexPage, ApexComponent in the same way

Step2. Select Apex template

1540365063496

Tips: search batch

1540365114644

Input your batch name

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
global class SampleBatch1 implements Database.Batchable<sObject> {
	
	String query;
	
	global SampleBatch1() {
		
	}
	
	global Database.QueryLocator start(Database.BatchableContext BC) {
		return Database.getQueryLocator(query);
	}

   	global void execute(Database.BatchableContext BC, List<sObject> scope) {
	
	}
	
	global void finish(Database.BatchableContext BC) {
		
	}
	
}

Update ApexClass

Change your apexclass,

Right click, SFDC-XY Metadata > Save To Server

1540365460463

Refresh From Server

Right click, SFDC-XY Metadata > Refresh From Server

1540366564885

Delete

Right click, SFDC-XY Metadata > Delete this metadata(Danger)

1540366621242

It will pop up a dialog like this.

1540366789444

Diff between localhost and server

Config your Winmerge

Project Setting > Open Project Config file

1540366215462

set your winmerge like below.

1
2
3
4
5
6
7
.......
	"app": {
        "Bash": "cmd /k cd /d {file_dir}", 
        "winmerge": "C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe", 
        "notepad": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe {file_name}"
    }, 
.......

Diff source

Right click, SFDC-XY Metadata > Diff with Server

1540365783795

1540366115227

if you do not set winmerge, it will use simple diff.

1540366430051

Find your source in sfdc

Right click, SFDC-XY Metadata > Save To Server

It will go to sfdc source page.

1540365563010

Deploy To SFDC

There are some different between Deploy and save.

Right click, SFDC-XY Metadata > Deploy To Server(Ant Migration Tool)

1540432504706

There 4 ways to deploy to sfdc server. If you select check only , it never actually saves to the server.

  • Deploy Open Files To Server:

  • Deploy Open Files To Server(check only):

  • Deploy Current File To Server : xxx.cls

  • Deploy Current File To Server : xxx.cls(check only)

1540432580625

Deploy the folder

choose your folder or source in sublime folders, then right click.

Find the menu : Sfdc-Xy > Deploy Directory To SFDC

1540445304166

Run Test Class

Right click, SFDC-XY Run > Run Test Class

1540442455878

Summary

Project

New Project

Project > New Project Input your project directory, and create your sfdc project

Switch Project

Project > Switch Project

Retrieve Source

Project > Retrieve Source Select metatdata type, and click Start To Retrieve to retrieve source. The old source src directory will be remove to src_backup

Retrieve Source zip

Project > Retrieve Source.zip Input your project directory, and retrieve zip.

Reload Metadata Cache

Project > Reload Metadata Cache Not need to Reload Metadata Cache.

Metadata

Create ApexClass, ApexTrigger, ApexPage, ApexComponent

Metadata > New ApexClass Metadata > New ApexTrigger Metadata > New ApexPage Metadata > New ApexComponent

Refresh Source

Metadata > Refresh From Server

Diff with Server

Metadata > Diff with Server If you want to use winmerge to check the different between local and server, Please config /.xyconfig/xyconfig.json, set winmerge. If you set winmerge blank, it will diff in sublime.

Tips: You must use \\ if you use Windows, such as "C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe"

Save To Server

Metadata > Save To Server

Deploy To Server

Please use Migration Tools to deploy sources. Migration Tool > Ant Migration Tool