How to Install SalesforceXytoolsForSublime

SalesforceXytoolsForSublime

SalesforceXytoolsForSublime is Rapid development tools for Salesforce Development.

  • Create Salesforce Project, Retrieve Metadata, Search Metadata

  • Create ApexClass, ApexTrigger, ApexComponent, Refresh, Diff with Server(Support winmerge diff), Save to Server, Deploy to Server

  • SObject Viewer, SObject Description, Export SOjbect Fields to Excel

  • Run SOQL Query, Tooling Query, Apex Script.

  • Code Creator : Auto Create Apex Test Class Code, Auto Create Test Data For Apex Test Class.

  • SFDC Dataviewer, SFDC Online Dataviewer.

  • Atuo Login SFDC (two login type: oauth2 , password config).

  • Quick local sfdc file from sublime.

  • Quick Search SObject Data/SObject Setting/ApexClass/Trigger/VisualForce Page/VisualForce Components/Email Template/Static Resource and open on browser Quickly

  • Package.xml Builder.

  • Build Release Package.

  • Integrate Sfdc Dataloader, Config DataLoader and Run (Need Ant and Java Environment)

Set your schedule, backup your sfdc data.

  • Integrate Sfdc Migration Tool (Need Ant and Java Environment)

  • Auto Backup all metadata script(Set your schedule, backup your sfdc metadata.).

How to Install

Prerequisites

Use Package Control to Install

  1. Open Sublime Text 3
  2. Run Package Control: Install Package command

  3. Search for SalesforceXyTools SalesforceXyToolsForSublimeHelp
  4. Hit Enter, That is all. SalesforceXyToolsForSublimeHelp

Suggestion

If you want to use ant-dataloader or ant-migration tools, I suggest you to install java and ant

Install java

just install it...

Please set your JAVA_HOME

Installing Apache Ant

Installing Apache Ant

To get up and running with the binary distribution of Ant quickly, follow these steps:

  1. Make sure you have a Java environment installed. See System Requirements for details.
  2. Download Ant. See Binary Distribution for details.
  3. Uncompress the downloaded file into a directory.
  4. Set environmental variables: JAVA_HOME to your Java environment, ANT_HOME to the directory you uncompressed Ant to, and add ${ANT_HOME}/bin (Unix) or %ANT_HOME%/bin (Windows) to your PATH. See Setup for details.
  5. Optionally, from the ANT_HOME directory run ant -f fetch.xml -Ddest=system to get the library dependencies of most of the Ant tasks that require them. If you don't do this, many of the dependent Ant tasks will not be available. See Optional Tasks for details and other options for the -Ddest parameter.
  6. Optionally, add any desired Antlibs. See Ant Libraries for a list.

How to Config SalesforceXytoolsForSublime

How to Config

SalesforceXytoolsForSublime

New Project

1539934585052

1539934552300

Config Project

Project Setting > Project Config Wizard

1539934605982

  • Select Sandbox Or Product
  • Input your username
  • Input your password
  • Input your security_token. If you haven't security_token, let it blank
  • Select your API Version

1539934624694

Proxy Config

Project Setting > Proxy Config Wizard 1539934831888

Start to develop sfdc

Login Test

SFDC > Login SFDC

Retrieve Metadata

1539934961510

Select metadata to retrieve

1540365204093

And Click Start To Retrive

Modify the config file.

You also can modify the config file in /.xyconfig/xyconfig.json. You can use Project Settings > Open Project Config File. Each project has a config file.

{
    "username": "input your username",
    "password": "input your password",
    "security_token": "",
    "is_sandbox": true,
    "api_version": 40.0,
    "src_dir": "src",
    "authentication": "password", 
    "jar_home": "C:\\Users\\exia\\salesforce-project\\jar", 
    "use_os_terminal": false, 
    "auto_save_to_server": false,
    "app" : {
        "winmerge": "C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe", 
        "notepad": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe {file_name}",
        "Bash" : "cmd /k cd /d {file_dir}"
    },
    "default_browser": "chrome", 
    "browsers": {
        "chrome": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", 
        "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe"
    }, 
    "debug_levels": {
        "Apex_Code": "DEBUG", 
        "Callout": "INFO", 
        "Workflow": "INFO", 
        "Apex_Profiling": "INFO", 
        "Validation": "INFO", 
        "DB": "Info", 
        "System": "DEBUG"
    },
    "proxy": {
        "use_proxy" : false,
        "proxyhost" : "127.0.0.1",
        "proxyport" : "8888",
        "proxyuser" : "proxyuser",
        "proxypassword" : "proxypassword"
    }
}

Config your login Browser

Add your browsers setting as below. You can use Project Settings > Switch Broswer to set your default browser.

// Add your browser which you like!
// examle:
// "firefox":"Path of firefox!",
"browsers":
{
    "chrome": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
    "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
    "Firefox": "C:\\Program Files\\Firefox.exe"
},

Use Oauth2 to access sfdc.

If you want to use oauth2 to access salesforce, please click Project Settings > Change Authentication Type to set your authentication type.

Use SalesforceXytoolsForSublime to develop SFDC

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

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.

.......
    "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

Export Sobject to Excel and Search Sobject

Topic

  1. Search sobject and view data
  2. Export Sobject Schema To Excel.

Environment

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

Sobject

Open SObject Manager Page

SObject > Search Sobject(Browser)

1540435396263

Search the sobject, then it will open the sobject manager page in browser.

1540435427892

1540435595332

View SObject Data In Browser

SObject > Open Sobject Data View(Browser)

1540435631881

Search the sobject, then it will open the data manager page in browser.

1540435726045

Export Sobject Schema To Excel

Sobject > Export Sobject Schema To Excel

1539935245815

Example,

1539935461910

Export SObject List To Txt

Sobject > Show Sobject List

1540435947703

Export SObject Data To Txt

Sobject > Export Sobject Data

1540436013078

1540436160738

summary

SObject

SObject > Search Sobject(Browser) SObject > Open Sobject Data View(Browser) Sobject > Export Sobject Schema To Excel Sobject > Show Sobject List Sobject > Export Sobject Data

Run sfdc soql, apex script, tooling api

Topic

  1. Run soql query
  2. Run apex script
  3. Run tooling query

Environment

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

Run Soql query

First, Select your soql

Then right click, SFDC-XY Run > SOQL Query

1540440544578

result :

1540440661762

Run Apex Script

select your apex script,

right click, SFDC-XY Run > Run Apex Script

1540441049661

Run Tooling query

select your tooling query,

right click, SFDC-XY Run > Tooling Query

1540441306919

Auto config salesforce ant-dataloader and Backup Sobject Data

Topic

  1. Auto config dataloader.
  2. Backup salesforce sobject data.

Environment

  • Set up your java and ant environment.
  • You must install java and ant before use ant dataloader.
  • You not need to Install the dataloader.
  • Make sure you can login your sfdc. Test it : SFDC-XY > Login SFDC

Tips : You not need to Install the dataloader, Salesforcexytools integrates with dataloader.

Auto Config Dataloader

Open Sublime-Menu : SFDC-XY > Dataloader > Build Ant Dataloader Configuration

1539931429520

Select Your Sobjects and Select Start To Config, example:

1539931785518

You can find AntDataloader in ./sfdc-xy/AntDataloader Folder.

1539931980132

Run AntDataloader

Ant command

cd ./sfdc-xy/AntDataloader
ant

1539932235973

Run in sublime

Dataloader > Run Ant Dataloader The data will be export to /sfdc-xy/AntDataloader/Export_YYYYMMDD_HHmm

1539932182175

config your soql

Open ./sfdc-xy/AntDataloader/build.xml

Add your export task, you can export sfdc sobject data easily.

    <target name="start_export">
        <!-- <export file="{FILE_NAME}" object="{SOBJECT_NAME}" soql="{SOQL}"/> -->
        <export file="Blog__c" object="Blog__c" soql="SELECT Id , Name , Title__c, Body__c FROM Blog__c"/>
        <export file="Log__c" object="Log__c" soql="SELECT Id , Name, Body__c FROM Log__c"/>
    </target>

Tips: Config the build.xml and copy Ant Dataloader to anywhere, and add your schedule job to export sfdc data.

Schedule Task , Auto Backup sfdc sobject data.

copy ./sfdc-xy/AntDataloader To any folder. and schedule task.

Auto config salesforce ant-migration-tools and Backup Metadata

Topic

  1. Auto config ant-migration-tools.
  2. Backup all salesforce metadata in one click. You do not need to config package.xml !

Environment

  • Set up your java and ant environment.
  • You must install java and ant before use ant dataloader.
  • You not need to Install the dataloader.
  • Make sure you can login your sfdc. Test it : SFDC-XY > Login SFDC

Auto Config ant-migration-tools

Sublime-Menu :SFDC-XY > Migration Tool > Ant Migration Tool

1539848350521

Select Config Ant Metadata Tool

1540431779525

Backup all Metadata

Sublime-Menu :SFDC-XY > Migration Tool > Ant Migration Tool

Select Backup All Metadata

1540431839856

It will take some time to backup all sfdc metadata. It will backup to the sfdc-xy\MetadataBackupTools\backup-metadata\

1540432165067

Tips : It is base on Ant Migration Tool .

Schedule Task , Auto Backup sfdc metadata.

You can find ant-migration-tools in ./sfdc-xy/MetadataBackupTools Folder.

You don't need to config package.xml.

Just copy MetadataBackupTools and config your system tasks

1539848747628

windows

In windows, you can set task like this.

1539849119939

1539849440133

Unix cron

You can set your cron job in unix/ linux/ mac

Export Sfdc Sobject Schema To Excel

Topic

  1. Export Sfdc Sobject Schema To Excel.

Environment

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

Sobject Schema To Excel

Open Sublime-Menu : SFDC-XY > Sobject > Export Sobject Schema To Excel

1539935245815

Example,

1539935461910

Use SalesforceXytoolsForSublime Salesforce Deploy Package

Topic

Example

Example, Open Account.object,Blog.page,BlogController.cls,Blog__c.object in Sublime

1539846980157

Sublime-Menu : SFDC-XY > Package Builder > Build Deploy package From Open Files

Input your save path

You can build package.xml like below.

src
  │  package.xml
  │
  ├─classes
  │      BlogController.cls
  │      BlogController.cls-meta.xml
  │
  ├─objects
  │      Account.object
  │      Blog__c.object
  │
  └─pages
          Blog.page
          Blog.page-meta.xml

about package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>
        <members>Blog</members>
        <name>ApexPage</name>
    </types>
    <types>
        <members>BlogController</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>Account</members>
        <members>Blog__c</members>
        <name>CustomObject</name>
    </types>
    <version>42.0</version>
</Package>

Salesforce package.xml Auto Builder

Topic

There are 2 ways to build package.xml 1. Build From SFDC API. 2. Use local file to build package.xml.

Build package.xml From Server

Sublime-Menu :SFDC-XY > Package Builder > Build Package.xml From Server

1539845253603

You can build package.xml like below.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>
        <members>*</members>
        <name>InstalledPackage</name>
    </types>
    <types>
        <members>*</members>
        <name>CustomLabels</name>
    </types>
    <types>
        <members>*</members>
        <name>StaticResource</name>
    </types>
   ............
   ............
   ............
   ............
   ............
   ............
   ............
   ............
    <types>
        <members>*</members>
        <name>Settings</name>
    </types>
    <version>42.0</version>
</Package>

Build package.xml From Open Files

Example, Open Account.object,Blog.page,BlogController.cls,Blog__c.object in Sublime

1539846980157

Sublime-Menu : SFDC-XY > Package Builder > Build package.xml From Open Files

You can build package.xml like below.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>
        <members>Blog</members>
        <name>ApexPage</name>
    </types>
    <types>
        <members>BlogController</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>Account</members>
        <members>Blog__c</members>
        <name>CustomObject</name>
    </types>
    <version>42.0</version>
</Package>

Summary

Package Builder

Build Package.xml From Server

Package Builder > Build Package.xml From Server Export all package.xml from server

Build Package.xml From Server From Open Files

Package Builder > Build Package.xml From Open Files

Build The deploy package from open files

Package Builder > Build Deploy Package From Open Files This is only copy the open files to a dir, not deploy to server.

How to export Apex Code Coverage

Topic

  1. Export Apex Code Coverage

Environment

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

Sobject

Open SObject Manager Page

ApexTest > Show Apex Code Coverage

1540443192921

Result

1540443323472

PermissionSet Builder

Topic

  1. Build permissionset file

Environment

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

Create Permission.xml

Open SObject Manager Page

Permission Builder> Build Profile FieldPermissions

1540457828769

Select your field

1540457987197

The Permissionset file :

<?xml version="1.0" ?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
  <fieldPermissions>
    <editable>true</editable>
    <field>Blog__c.comment__c</field>
    <readable>true</readable>
  </fieldPermissions>
  <objectPermissions>
    <allowCreate>true</allowCreate>
    <allowDelete>true</allowDelete>
    <allowEdit>true</allowEdit>
    <allowRead>true</allowRead>
    <modifyAllRecords>true</modifyAllRecords>
    <object>Blog__c</object>
    <viewAllRecords>true</viewAllRecords>
  </objectPermissions>
  <hasActivationRequired>false</hasActivationRequired>
  <label>AllPermission</label>
  <license>Salesforce</license>
</PermissionSet>

Deploy permission.xml

right click , deploy it.

Soql Creator

Topic

Environment

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

Create Soql

SFDC Code Creator > Create Soql

1540459992691

Select Soql Type

1540460017305

result :

select 
            Id,             //カスタムオブジェクト ID
            OwnerId,                //所有�ID
            IsDeleted,              //削除
            Name,               //ブログNo
            RecordTypeId,               //レコードタイ�ID
            CreatedDate,                //作成�
            CreatedById,                //作成�ID
            LastModifiedDate,               //最終更新日
            LastModifiedById,               //最終更新�ID
            SystemModstamp,             //System Modstamp
            LastViewedDate,             //最終閲覧日
            LastReferencedDate,             //最終参照日
            comment__c,             //評価
            comment_status__c,              //評価ステータ�
            content__c,             //内容
            excerpt__c,             //概要
            status__c,              //ステータ�
            title__c,               //タイトル
            ReadOnlyTest__c,                //ReadOnlyTest
            FormulaTest__c,             //数式テス�
            Account__c              //取引�
from Blog__c

Save Your Sfdc Module and build a deploy module package

Topic

Environment

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

Save a module

Open the source.

1540519797063

Right Click , SFDC-XY Toolbox> Save Module(From Open Files)

1540519843822

Input your save path

1540519944813

Check your module

1540521537775

Deploy your module

fix your target sfdc info

open build.properties

sf.username = {username}
sf.password = {password}
##sf.sessionId = <Insert your Salesforce session id here.  Use this or username/password above.  Cannot use both>
##sf.pkgName = <Insert comma separated package names to be retrieved>
##sf.zipFile = <Insert path of the zipfile to be retrieved>
##sf.metadataType = <Insert metadata type name for which listMetadata or bulkRetrieve operations are to be performed>

## Use 'https://login.salesforce.com' for production or developer edition (the default if not specified).
## Use 'https://test.salesforce.com for sandbox.
sf.serverurl = {serverurl}
sf.maxPoll = 500
sf.pollWaitMillis = 10000
## If your network requires an HTTP proxy, see http://ant.apache.org/manual/proxy.html for configuration.
##

windows

only check your code: click deployCodeCheckOnly.bat only!

deploy your code: click deployCodeRunLocalTests.bat only!

Linux/Mac

only check your code

ant deployCodeCheckOnly

deploy your code

ant deployCodeRunLocalTests

Search sfdc metadata

Topic

Environment

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

Search Metadata

SFDC-XY > Search Metadata

1540532540638

Select metadata type.

1540532580583

For example, Select Profile, You can find the list of metadata.

Selcet Admin.profile, It will jump to sfdc Admin profile page.

1540532640276

1540532907894

Support Metadata Type

Copy a Lightning Component

Topic

Environment

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

Copy Lightning Component

Select your Lightning component.

1540539008255

Right Click, SFDC-Xy > Copy Lightning Component.

1540539047383

Input your new component name.

1540539148418

Check the new component. 1540539896624

Deploy The component

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

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

1540445304166

Lightning Web Components HelloWorld

Topic

In this project, you’ll:

Config Salesforcexytools

How to Config Salesforcexytools.

Please set your api 45.0

1545965650321

Create a Hello World Lightning Web Component

create a Lightning web component.

The Source is From Create a Hello World Lightning Web Component

Create source in sublime, like below:

1545964554803

helloWorld.html

<template>
    <lightning-card title="HelloWorld" icon-name="custom:custom14">
        <div class="slds-m-around_medium">
            <p>Hello, {greeting}!</p>
            <lightning-input label="Name" value={greeting} onchange={changeHandler}></lightning-input>
        </div>
    </lightning-card>
</template>

helloWorld.js

import { LightningElement, track } from 'lwc';
export default class HelloWorld extends LightningElement {
    @track greeting = 'World';
    changeHandler(event) {
        this.greeting = event.target.value;
    }
}

helloWorld.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__AppPage</target>
    <target>lightning__RecordPage</target>
    <target>lightning__HomePage</target>
  </targets>
</LightningComponentBundle>

Deploy a Lightning web component

Right Click -> Deploy Directory To Server

1545965045120

Select Deploy Direcotry

1545965073324

Click Yes!

1545965134397

Check the log

1545965313466

Add Component to App in Lightning Experience

Please read Create a Hello World Lightning Web Component

Resources

Introducing Lightning Web Components

Quick Start: Lightning Web Components

Auto Create Salesforce VisualForce Apex

Topic

  • Use SalesforceXytoolsForSublime To Auto Create VisualForce・Apex Controller・DTO・DAO

  • Auto Build Detail Page

    • Record Input Page
    • Record Review Form
    • Save the Record
  • Auto Build Record List Page
    • List All Records.
    • Search Record
    • Mass Edit Records
    • Records Review Form

Environment

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

Auto Create VF-Controller-DTO-DAO-Code

Tips: It just create the code in the localhost. It will not deploy to your sfdc server.

Find the menu

SFDC Code Creator > Create VisualForce/Controller/DTO/DAO Code

1540444254303

Choose your Sobject.

I will select Blog__c.

1540444395082

About Blog__c:

1540535859753

Select Custom Fields Or All Fields.

I will select 1.Custom fields Only(Exculde Validate).

1540444454039

When It is done , It will show the popup like below.

There are many source will be opened if you choose ok.

1540444924569

You can find the source in ./src_sfdc_module/code-creator/src

1540445085932

Deploy the codes

choose the src, then right click, Sfdc-Xy > Deploy Directory To SFDC

1540445304166

Tips : If you build a complex page , maybe you can not deploy correctly. Fix the codes, then deploy them.

Run it

visit the visualforce page

Detail Page.

  • Record Input Page
  • Record Review Form
  • Save the Record

Page URL : https://{instance}.salesforce.com/apex/Blog

Input Form

1540536475265

Review Form

Input something, then click next, then it will go to Review Form

1540536538782

1540536818611

click save, you can save the data.

Record List Page

  • List All Records.
  • Search Record
  • Mass Edit Records
  • Records Review Form

URL : https://{instance}.salesforce.com/apex/BlogList

List All Records

1540537365308

Search Record

Tips: The Picklist will be changed to filter.

Select the filter, and search the data.

1540537722015

1540537883121

Mass Edit Records

Edit records , and click next

1540538022704

Records Review Form

Go to the review form, and click save button.

1540538069994

Go back to the list page, check the result.

1540538151435

Salesforce test code creator

Topic

  1. Auto Create test class.
  2. Soql to apex code.

Environment

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

Write a test class

Auto Create TestCode

Tips: It just create the code in the localhost. It will not deploy to your sfdc server.

Open the apex code, Right click.

sample code:

/**
* @author huangxy
*/
public with sharing class BlogController extends SfdcXyController {

        // DTO Bean
        public BlogDto blogDto {get;set;}

        public BlogController() {
            search();
        }

        private void search(){
            String id = ApexPages.currentPage().getParameters().get('id');
            if(String.isBlank(id)){
                this.blogDto = new BlogDto();
            }else{
                this.blogDto = new BlogDto(BlogDao.getBlogById(id));
            }
        }

        /**
         * upsert Dto
         */
        public PageReference doSave() {
            Boolean result;

            Savepoint sp = Database.setSavepoint();
            try {
                upsert blogDto.getSobject();
                result = true;
            } catch(DMLException e) {
                Database.rollback(sp);
                System.debug('saveDto DMLException:' + e.getMessage());
                result = false;
            } catch(Exception e) {
                Database.rollback(sp);
                System.debug('saveDto Exception:' + e.getMessage());
                result = false;
            }
            return null;
        }

        /**
         * Go Next
         */
        public override PageReference doNext() {
            Boolean result = doCheck();
            setNextMode(result);
            return null;
        }

        /**
         * Go Back
         */
        public override PageReference doBack() {
            Boolean result = true; 
            setBackMode(result);
            return null;
        }

        /**
         * do Check
         */
        public override Boolean doCheck() {
            Boolean result = true;

            return result;
        }
}

Right click, SFDC-XY Code Creator >Create test code

1540449212136

It will be create a test class like this:

/**
* @author huangxy
*/
@isTest
private class BlogControllerTest {

    /**
     * This is a test method for BlogController
     */
    static testMethod void test_BlogController() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        BlogController blogController = new BlogController();


        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


    /**
     * This is a test method for doSave
     */
    static testMethod void test_doSave() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        BlogController blogController = new BlogController();
        PageReference resultDoSave = blogController.doSave();


        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


    /**
     * This is a test method for doNext
     */
    static testMethod void test_doNext() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        BlogController blogController = new BlogController();
        PageReference resultDoNext = blogController.doNext();


        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


    /**
     * This is a test method for doBack
     */
    static testMethod void test_doBack() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        BlogController blogController = new BlogController();
        PageReference resultDoBack = blogController.doBack();


        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


    /**
     * This is a test method for doCheck
     */
    static testMethod void test_doCheck() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        BlogController blogController = new BlogController();
        Boolean resultDoCheck = blogController.doCheck();


        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


    /**
     * This is a test method for all
     */
    static testMethod void test_all() {

        // PageReference pageRef = Page.Blog;
        // Test.setCurrentPage(pageRef);
        // pageRef.getParameters().put('param1', 'param1');

        Test.startTest();

        //  test BlogController
        BlogController blogController = new BlogController();

        //  test doSave
        PageReference resultDoSave = blogController.doSave();

        //  test doNext
        PageReference resultDoNext = blogController.doNext();

        //  test doBack
        PageReference resultDoBack = blogController.doBack();

        //  test doCheck
        Boolean resultDoCheck = blogController.doCheck();



        Test.stopTest();

        // Check
        // System.assert(ApexPages.hasMessages());
        // for(ApexPages.Message msg : ApexPages.getMessages()) {
        //     System.assertEquals('Upload file is NULL', msg.getSummary());
        //     System.assertEquals(ApexPages.Severity.ERROR, msg.getSeverity());
        // }
    }


}

Insert test data from Soql

Insert Test Data(From SOQL)

Input a soql query string.

select id,name,comment__c,content__c from Blog__c limit 2

1540449792963

Right click, SFDC-XY Code Creator > Insert Test Data(From Soql)

1540449870938

The sql will be change to apex code like below.

```java List blogList = new List(); Blog__c blog0 = new Blog__c(); // blog0.id = 'a006F00002pzN2TQAU'; // カスタムオブジェクト ID blog0.name = 'ID-0013'; // ブログNo // blog0.comment__c = ''; // 評価 blog0.content__c = 'test 承認プロセステス�; // 内容 blogList.add(blog0);

    Blog__c blog1 = new Blog__c();
    // blog1.id = 'a006F00002k90XhQAI';    // カスタムオブジェクト ID
    blog1.name = 'ID-0000';   // ブログNo
    blog1.comment__c = '11';   // 評価
    blog1.content__c = 'AHVI0uh0';   // 内容
    blogList.add(blog1);

    upsert blogList;

```

Insert random test data

Right click, SFDC-XY Code Creator > Insert Test Data(All Field) or

SFDC-XY Code Creator > Insert Test Data(Needed Field)

1540457409043

Select your sobject, It will create code like below.

List<Blog__c> blogList = new List<Blog__c>();
for(Integer i=0; i<5; i++){
    Blog__c blog = new Blog__c();
    blog.RecordTypeId = recordtypeidList[i].id;    //レコードタイ�ID
    blog.comment__c = '3VG5bF0' + string.valueof(i) ;    //評価
    blog.comment_status__c = 'approve';    //評価ステータ�
    blog.content__c = '6p8psSh' + string.valueof(i) ;    //内容
    blog.excerpt__c = 'YLpQQAw' + string.valueof(i) ;    //概要
    blog.status__c = 'Draft';    //ステータ�
    blog.title__c = 'ot9xvaa' + string.valueof(i) ;    //タイトル
    blog.ReadOnlyTest__c = 'ld9IPfB' + string.valueof(i) ;    //ReadOnlyTest
    blog.Account__c = accountList[i].id;    //取引�
    blogList.add(blog);
}
insert blogList;


SalesforceXytoolsForSublime Reference

SalesforceXytoolsForSublime

SalesforceXytoolsForSublime is Rapid development tools for Salesforce Development.

  • Create Salesforce Project, Retrieve Metadata, Search Metadata

  • Create ApexClass, ApexTrigger, ApexComponent, Refresh, Diff with Server(Support winmerge diff), Save to Server, Deploy to Server

  • SObject Viewer, SObject Description, Export SOjbect Fields to Excel

  • Run SOQL Query, Tooling Query, Apex Script.

  • Code Creator : Auto Create Apex Test Class Code, Auto Create Test Data For Apex Test Class.

  • SFDC Dataviewer, SFDC Online Dataviewer.

  • Atuo Login SFDC (two login type: oauth2 , password config).

  • Quick local sfdc file from sublime.

  • Quick Search SObject Data/SObject Setting/ApexClass/Trigger/VisualForce Page/VisualForce Components/Email Template/Static Resource and open on browser Quickly

  • Package.xml Builder.

  • Build Release Package.

  • Integrate Sfdc Dataloader, Config DataLoader and Run (Need Ant and Java Environment)

Set your schedule, backup your sfdc data.

  • Integrate Sfdc Migration Tool (Need Ant and Java Environment)

  • Auto Backup all metadata script(Set your schedule, backup your sfdc metadata.).

Basic on OpenSource

SalesforceXyToolsForSublime is based on python and open source below.

  1. xlsxwriter (License: BSD)
  2. Simple-Salesforce (License: Apache 2.0)
  3. requests (License: Apache 2.0)

SalesforceXyToolsForSublime Reference

Document Reference

Download PDF

About Author : Exia.Huang

Other tools for salesforce

SalesforceXyTools for Chrome is a developer tools for Salesforce,SFDC,Force.com. Login SFDC By 1 click. Quickly Search Metadata Sobject,Apex,Trigger,Page,Component,EmailTemplate,SataticResource, etc. Auto Create Soql, Run Soql, Soql History. Run Apex Script. Quick Search SFDC Document.