SalesforceXyTools Sublime ApexCreator

概要

SalesforceXyTools

Auto Create VF-Controller-DTO-DAO-Code

Hello,I am Exia.huang.
Today I will show you how to create VisualForce/Apex quickly by using SalesforceXyTools.

There are 5 steps.

  1. Find the menu below.
    [SFDC-XY]->[SFDC Code Creator]->[Create VisualForce/Controller/DTO/DAO Code]

  2. Select your Sobject.
    I will select Blog__c.

  3. Select Custom Fields Or All Fields.

    • I will select custom fields-Include Validate.

    • The sobject of Blog__c is as below:

  4. It will automatically create code like below

    1
    2
    3
    4
    5
    6
    7
    8
    9
    +---sfdc-xy
    | \---code-creator
    | Blog.page
    | BlogController.cls
    | BlogDao.cls
    | BlogDto.cls
    | BlogList.page
    | BlogListController.cls
    | SfdcXyController.cls
  1. Upload these code and enjoy yourself.

    1
    2
      https://ap2.salesforce.com/apex/BlogList
      https://ap2.salesforce.com/apex/Blog
    • Edit list of Blog__c.(Source code is BlogList.page.)

    • View list of Blog__c.(Source code is BlogList.page.)

    • Search Blog__c Data.(Source code is BlogList.page.)

    • New a Blog__c Data.(Source code is Blog.page.)

    • New a Blog__c Data.(Source code is Blog.page.)

    • Edit a Blog__c Data.(Source code is Blog.page.)

SalesforceXyTools Sublime Export SObject To Excel

概要

SalesforceXyTools Sublimeを使ってSobjectをエクセルファイルにエクスポート

SalesforceXyTools

SalesforceXyTools Export Soject To Excel

Hello,I am Exia.huang.
Today I will show you how to export soject to excel.

There are 3 steps.

  1. Find the menu below.
    [SFDC-XY]->[SFDC Object]->[Save SFDC Object List AS Excel]

  2. Input your save path and xlsx file name.

  3. Open the excel file, and enjoy yourself.

SalesforceXyTools Sublime Test Code Creator

SalesforceXyTools

Auto Create VF-Controller-DTO-DAO-Code

Hello,I am Exia.huang.
Today I will show you how to create testclass quickly by using SalesforceXyTools.
And how to create to create test data quickly.

##

  1. Open the apex code, and find the menu below.
    [SFDC-XY]->[SFDC Code Creator]->[Create Test Code]

    • The class code which I have selected is like below.
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
      100
      101
      102
      103
      104
      105
      106
      107
      108
      109
      110
      111
      112
      113
      114
      115
      116
      117
      118
      119
      120
      121
      122
      123
      124
      125
      126
      127
      128
      129
      130
      131
      132
      133
      134
      135
      136
      137
      138
      139
      140
      141
      142
      143
      144
      145
      146
      147
      148
      149
      150
      151
      152
      153
      154
      155
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      210
      211
      212
      213
      214
      215
      216
      217
      218
      219
      220
      221
      222
      223
      224
      225
      226
      227
      228
      229
      230
      231
      232
      233
      234
      235
      236
      237
      238
      239
      240
      241
      242
      243
      244
      245
      246
      247
      248
      249
      /**
      * @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;
      }
      }
      ```
      * Select [Create Test Code], the test code will be created automatically like below.
      ```java
      /**
      * @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());
      // }
      }
      }
  2. Insert Test Data(All Field)
    I will select Blog__c.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    List<Blog__c> blogList = new List<Blog__c>();
    for(Integer i=0; i<5; i++){
    Blog__c blog = new Blog__c();
    blog.comment__c = 'CoaM5Vy' + string.valueof(i) ; //評価
    blog.comment_status__c = 'spam'; //評価ステータス
    blog.content__c = 'biKtXlF' + string.valueof(i) ; //内容
    blog.excerpt__c = 'QVbhcE8' + string.valueof(i) ; //概要
    blog.status__c = 'Draft'; //ステータス
    blog.title__c = '52lF1IP' + string.valueof(i) ; //タイトル
    blogList.add(blog);
    }
    insert blogList;
  3. Insert Test Data(From SOQL)

    1
    select id,name,comment__c,content__c from Blog__c limit 2
    • Select [Insert Test Data(From SOQL) ] Menu, the sql will be change to apex code like below.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    List<Blog__c> blogList = new List<Blog__c>();
    Blog__c blog0 = new Blog__c();
    // blog0.id = 'a096F00001yVNHWQA4'; // カスタムオブジェクト ID
    blog0.name = 'ID-0004'; // ブログNo
    blog0.comment__c = '評価'; // 評価
    blog0.content__c = '評価'; // 内容
    blogList.add(blog0);
    Blog__c blog1 = new Blog__c();
    // blog1.id = 'a096F00001yVNHRQA4'; // カスタムオブジェクト ID
    blog1.name = 'ID-0003'; // ブログNo
    blog1.comment__c = '評価1e'; // 評価
    blog1.content__c = '内容'; // 内容
    blogList.add(blog1);
    upsert blogList;

SalesforceXyTools Sublime Install Help

SalesforceXyTools

SalesforceXyTools Install Help

Prerequisites

Plugin Installation(Use Package Control to Install)

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

  3. Search for SalesforceXyTools

  4. Hit Enter, That is all.

SalesforceXyTools Sublime Mavensmate Setup

Use Mavensmate Session

  • If you like to use mavensmate’s setting, you can set authentication mavensmate.
  • mavensmate-destop v0.0.10 or below, please set mm_use_keyring true.
  • mavensmate-destop v0.0.11-beta.2 to v0.0.11-beta.7, please set mm_use_keyring false.
1
"authentication":"mavensmate",

mavensmate-destop v0.0.10 or below, please set mm_use_keyring true.
please re-auth again, Or Create project again!
This is the default value of mavensmate-destop!!!

mavensmate-destop v0.0.11-beta.2 to v0.0.11-beta.7, please set mm_use_keyring false.
please re-auth again, Or Create project again!

SalesforceXyTools Sublime Install Help Old Manual

This is an old manual, please use the new one blow.

SalesforceXyTools Sublime Install Help

#Github下载链接 SalesforceXyTools.sublime-package
https://github.com/exiahuang/SalesforceXyTools/releases

#Ibmer.Info地址
http://www.ibmer.info/salesforcexytools.html

#GitHub地址
https://github.com/exiahuang/SalesforceXyTools

install SalesforceXyTools.sublime-package

  1. Open sublime Text, Click the Preferences > Browse Packages… menu
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Download Package SalesforceXyTools.sublime-package and copy it into the Installed Packages/ directory
  4. Restart Sublime Text

*Download SalesforceXyTools.sublime-packag
download.jpg

*Setup SalesforceXyTools.sublime-packag
setup.jpg

#about mavensmate version

#安装配置
1.打开Sublime安装路径下的 \Data\Installed Packages 目录,复制SalesforceXyTools.sublime-package到该目录下。
{Sublime Text安装路径}\Data\Installed Packages。

2运行Sublime, [SFDC-XY]->[Settings]->[Settings Default]复制所有内容,

3.打开 [SFDC-XY]->[Settings]->[Settings User],粘贴2所复制的内容。

4.如果你使用mavensmate开发salesforce,那么请用默认配置即可。

如果你不使用mavensmate开发salesforce,那么设置”use_mavensmate_setting”:false,然后设置你的default_project and projects。

  • 请使用mavensmate v0.0.10一下版本,v0.0.11-beta.2到v0.0.11-beta.7版本暂时不支持*
  • mavensmate v0.0.10*

#インストール手順書(日本語)

1.SalesforceXyTools.sublime-packageをダウンロードしてください。

https://github.com/exiahuang/SalesforceXyTools/releases

2.Sublime Text3を起動します。

3.メニューの「Preferences」→「Browse Packages…」を選択します。

「Packages」というフォルダが開かれます。
「Packages」の親フォルダの中に「Installed Packages」というフォルダが有ります。

パス確認{Sublime Textのインストールパス}\Data\Installed Packages。

4.「Installed Packages」フォルダの中に、先ほどダウンロードした「SalesforceXyTools.sublime-package」ファイルを入れます。

5.Sublime Text3を再起動すれば、SalesforceXyToolsが動作しています。

6.設定について、もしmavensmateを使っている場合、use_mavensmate_settingをTrueに設定してください。
  mavensmateを使っていない場合、use_mavensmate_settingをFalseに設定してください。

  • mavensmate v0.0.10をサポートしますが、*
  • v0.0.11-beta.2 から v0.0.11-beta.7までのバージョンばしばらくサポートしません。*

Salesforce apex updateあるいはdeleteしたらDmlExceptionが出た

Salesforce apex updateあるいはdeleteしたらDmlExceptionが出た

1
2
3
First error: Update failed.
First exception on row 0 with id a08xxxxxxxxxxxxxxx;
first error: ENTITY_IS_DELETED, entity is deleted: []

削除したオブジェクトは参照でできないから。

「ENTITY_IS_DELETED」なのどコードの意味は?

SFDC Developer Guide

1
2
3
You can’t reference an object that has been deleted.
This status code occurs only in API version 10.0 and later.
Previous releases of the API use INVALID_ID_FIELD for this error.

dos comment

Dos BAT Comment

  1. :: 注释内容(第一个冒号后也可以跟任何一个非字母数字的字符)
  2. rem 注释内容(不能出现重定向符号和管道符号)
  3. echo 注释内容(不能出现重定向符号和管道符号)〉nul
  4. if not exist nul 注释内容(不能出现重定向符号和管道符号)
  5. :注释内容(注释文本不能与已有标签重名)
  6. %注释内容%(可以用作行间注释,不能出现重定向符号和管道符号)
  7. goto 标签 注释内容(可以用作说明goto的条件和执行内容)
  8. :标签 注释内容(可以用作标签下方段的执行内容)

example

1
2
3
4
5
echo on
rem this is a comment.
echo this is a comment.
:: this is a comment too.
echo this is a comment too.