Auto Create VF-Controller-DTO-DAO-Code

SalesforceXyTools

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] SOS
  2. Select your Sobject. I will select Blog__c. SOS
  3. Select Custom Fields Or All Fields.

    • I will select custom fields-Include Validate. SOS
    • The sobject of Blog__c is as below: SOS
  4. It will automatically create code like below

    +—sfdc-xy
    | -–code-creator
    | Blog.page
    | BlogController.cls
    | BlogDao.cls
    | BlogDto.cls
    | BlogList.page
    | BlogListController.cls
    | SfdcXyController.cls
    `
    SOS

  5. Upload these code and enjoy yourself.

    `  https://ap2.salesforce.com/apex/BlogList
    https://ap2.salesforce.com/apex/Blog

    • Edit list of Blog__c.(Source code is BlogList.page.) SOS
    • View list of Blog__c.(Source code is BlogList.page.) SOS
    • Search Blog__c Data.(Source code is BlogList.page.) SOS
    • New a Blog__c Data.(Source code is Blog.page.) SOS
    • New a Blog__c Data.(Source code is Blog.page.) SOS
    • Edit a Blog__c Data.(Source code is Blog.page.) SOS
      Link:

http://www.ibmer.info/auto-create-sfdc-code.html

 

 

 

 

 

Salesforce快速开发工具SalesforceXyTools

SalesforceXyTools

SalesforceXyTools

SalesforceXyTools for Sublime Text is Rapid development tools for Salesforce Development.

  • Auto Create Apex Test Class Code, Auto Create Test Data For Apex Test Class.
  • SFDC Dataviewer, SFDC Online Dataviewer.
  • SObject Viewer, SObject Description, Export SOjbect Fields to Excel
  • Atuo Login SFDC.
  • SOQL Query, Tooling Query, Run Apex Script.

Install SalesforceXyTools(Use Package Control to Install)

1. Open Sublime Text 3
2. Run Package Control: Install Packagecommand 3\. Search for SalesforceXyTools
4. Hit Enter

##

安装配置

1.打开Sublime3

2运行Package Control: Install Package 命令

3.查找SalesforceXyTools,并回车安装。

インストール手順書

1.Sublime3を開く

2「Package Control: Install Package 」コメントを実行

3. 「SalesforceXyTools」を検索して,インストールしてください。

Setup

Important Settings

Use Mavensmate Session

■Only Support for v0.0.10, or Below!!

■Not Support for v0.0.11-beta.2 to v0.0.11-beta.7, because of MavensMate v0.0.11-beta.2 or above uses OAuth!

You may set use_mavensmate_setting to a single path on your local filesystem or an array of paths. If you set use_mavensmate_setting true, you can use all the setting of mavensmate, you need not to set projects or default_project .

1
2
3
//Only Support for v0.0.10
//Not Support for v0.0.11-beta.2 to v0.0.11-beta.7
"use_mavensmate_setting" : true
`</pre> #### [](https://github.com/exiahuang/SalesforceXyTools#use-projects-setting)Use `projects` Setting If you set `use_mavensmate_setting` false, please set the `default_project` and `projects` as the example. ##### [](https://github.com/exiahuang/SalesforceXyTools#examples-of-projects)Examples of projects <pre>`"default_project":"huangxy1", "projects": { "huangxy1": { "loginUrl": "https://login.salesforce.com", "password": "XXXXXXX", "security_token": "XXXXXXXXXXXXXXX", "username": "XXXXXXX@ibmer.info", "api_version": 36.0, "is_sandbox": false, "workspace": "C:/workspace/huangxy1/" }, "huangxy2": { "loginUrl": "https://test.salesforce.com", "password": "XXXXXXX", "security_token": "XXXXXXX", "username": "XXXXXXX@ibmer.info", "api_version": 36.0, "is_sandbox": true, "workspace": "C:/workspace/huangxy2/" } } `</pre> Add your `browsers` setting as below <pre>` // Add your browser which you like! // examle: // "firefox":"Path of firefox!", // "Edge":"Path of Edge", or another "browsers": { "chrome": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe" }, `</pre> <pre>` `</pre> ## Usage #### [](https://github.com/exiahuang/SalesforceXyTools#run-soqlrun-tooling-api)Run SOQL/Run Tooling api Select your SOQL, [SFDC-XY] -&gt; [SFDC SOQL] -&gt; [SOQL Query]/[Tooling Query] and run! [![Run SOQL](https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/sfdc_soql.gif?raw=true)](https://github.com/exiahuang/XyHelp/blob/master/SalesforceXyTools/sfdc_soql.gif?raw=true) #### [](https://github.com/exiahuang/SalesforceXyTools#sfdc-object-descript-save-as-excel)SFDC Object Descript, Save as Excel Path: [SFDC-XY] -&gt; [SFDC Object] [![SFDC Object](https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/sfdc_object.gif?raw=true)](https://github.com/exiahuang/XyHelp/blob/master/SalesforceXyTools/sfdc_object.gif?raw=true) #### [](https://github.com/exiahuang/SalesforceXyTools#sfdc-dataviewer)SFDC DataViewer Path: [SFDC-XY] -&gt; [SFDC Dataviewer] [![SFDC Object](https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/dataviwer.gif?raw=true)](https://github.com/exiahuang/XyHelp/blob/master/SalesforceXyTools/dataviwer.gif?raw=true) #### [](https://github.com/exiahuang/SalesforceXyTools#create-test-code)Create Test Code Open your apex code, [SFDC-XY] -&gt; [SFDC Code Creator] -&gt; [Create Test Code] and you can auto creat your apex test class!! [![Create Test Code](https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/test_class_create.gif?raw=true)](https://github.com/exiahuang/XyHelp/blob/master/SalesforceXyTools/test_class_create.gif?raw=true) #### [](https://github.com/exiahuang/SalesforceXyTools#apexcontroller--viewer--testclass-quick-jump)ApexController , Viewer , TestClass Quick Jump Right Click, and find the click! [![Controller_VF_Jump](https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/Controller_VF_Jump.gif?raw=true)](https://github.com/exiahuang/XyHelp/blob/master/SalesforceXyTools/Controller_VF_Jump.gif?raw=true) &nbsp; * * * &nbsp; ## &nbsp; ## More Link About SalesforceXyTools [https://github.com/exiahuang/SalesforceXyTools/releases](https://github.com/exiahuang/SalesforceXyTools/releases) Ibmer.Info地址 [http://www.ibmer.info/salesforcexytools.html](http://www.ibmer.info/salesforcexytools.html) GitHub地址 [https://github.com/exiahuang/SalesforceXyTools](https://github.com/exiahuang/SalesforceXyTools) ## Help Link 1.Auto Create Salesforce Test Code. 生成测试代码 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/test_class_create.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/test_class_create.gif) 2.Data View . 数据浏览 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/dataviwer.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/dataviwer.gif) 3.Export SFDC Object to Excel. 表结构导出Excel [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_object.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_object.gif) 4.Run SOQL/Apex. SOQL/Apex执行 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_soql.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_soql.gif) 5.Jump between ApexController , page , TestClass ApexController , page , TestClass相互跳转 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/Controller_VF_Jump.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/Controller_VF_Jump.gif) 6.Auto Login Project 自动登录选择的项目,可以选择浏览器 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/login_project.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/login_project.gif) 7.Soql Query. 执行Select * 语句 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/select_all.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/select_all.gif) 8.Auto Create Soql 自动创建Soql语句 [https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/auto_soql.gif](https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/auto_soql.gif) <pre>`

SFDC Bluk job Error:Failed to process query: FUNCTIONALITY_NOT_ENABLED: Selecting compound data not supported in Bulk Query

执行bluk job 出现下面错误。。。

Failed to process query: FUNCTIONALITY_NOT_ENABLED: Selecting compound data not supported in Bulk Query

这里有一个解决方案,是屏蔽掉address类型的字段后执行soql。。很变态的sfdc,无语了。。

https://github.com/jsforce/jsforce/issues/380

js代码如下

conn.sobject(‘Account’).describe(function(ret) {
var fields = ret.fields.filter(function(f) {
return f.type !== ‘address’; // filter any fields you don’t want to include in query.
}).map(function(f) {
return f.name;
});
var soql = ‘SELECT ‘ + fields.join(‘, ‘) + ‘ FROM Account’;
return conn.bulk.query(soql);
})

python也是一样这样的错误。。。

Salesforce快速开发工具SalesforceXyTools-Delete

前言

经过了1一个多月的努力,Salesforce快速开发工具终于扔到开源社区SalesforceXyTools。

虽然里面还有许多Bug,不过基本好多实用的小工具也是正常能使用。

现在还不能直接通过Sublime下载,希望尽快审核通过。

 

1/16号通过了Sublime的审核,现在可以直接下载了。

通过Sublime Package Control安装

1. Open Sublime Text 3
2. Run Package Control: Install Package command
3. Search for SalesforceXyTools
4. Hit Enter

 

Github下载链接

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

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

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

安装配置

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。

 


インストール手順書

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

https://github.com/exiahuang/XyHelp/raw/master/SalesforceXyTools/SalesforceXyTools.sublime-package

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を使っている場合、設定しなくてもよいです!!

mavensmateを使っていない場合、https://github.com/exiahuang/SalesforceXyToolsを参照ください。


Salesforce开源工具(SalesforceXyTools)使用说明

1.生成测试代码
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/test_class_create.gif

2.数据浏览
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/dataviwer.gif

3.表结构导出Excel
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_object.gif

4.SOQL/Apex执行
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/sfdc_soql.gif

5.ApexController , page , TestClass相互跳转
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/Controller_VF_Jump.gif

6.自动登录选择的项目,可以选择浏览器
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/login_project.gif

7.执行Select * 语句
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/select_all.gif

8.自动创建Soql语句
https://raw.githubusercontent.com/exiahuang/XyHelp/master/SalesforceXyTools/auto_soql.gif

 

SalesforceXyTools

SalesforceXyTools for Sublime Text is Rapid development tools for Salesforce Development.

  • Auto Create Apex Test Class Code, Auto Create Test Data For Apex Test Class.
  • SFDC Dataviewer, SFDC Online Dataviewer.
  • SObject Viewer, SObject Description, Export SOjbect Fields to Excel
  • Atuo Login SFDC.
  • SOQL Query, Tooling Query, Run Apex Script.

Basic on OpenSource

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

All issues are managed by the SalesforceXyTools

Install

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

Plugin Installation(Use Source package)

  1. Download SalesforceXyTools
  2. Open Sublime Text 3
  3. Prefences -> Browse Packages
  4. Extra zip file which you download

    Extra path Example:
    {Path Of Sublime Text}\Data\Packages\SalesforceXyTools
    
    Ensure the path is correct!!
    

    `

    Setup

    Important Settings

    Use Mavensmate Session

    You may set use_mavensmate_setting to a single path on your local filesystem or an array of paths. If you set use_mavensmate_setting true, you can use all the setting of mavensmate, you need not to set projects or default_project .

    `"use_mavensmate_setting" : true
    `

    Use projects Setting

    If you set use_mavensmate_setting false, please set the default_project and projects as the example.

    Examples of projects
    `"default_project":"huangxy1",
     "projects":
        {
            "huangxy1":
            {
                "loginUrl": "https://login.salesforce.com",
                "password": "XXXXXXX",
                "security_token": "XXXXXXXXXXXXXXX",
                "username": "XXXXXXX@ibmer.info",
                "api_version": 36.0,
                "is_sandbox": false,
                "workspace": "C:/workspace/huangxy1/"
            },
            "huangxy2":
            {
                "loginUrl": "https://test.salesforce.com",
                "password": "XXXXXXX",
                "security_token": "XXXXXXX",
                "username": "XXXXXXX@ibmer.info",
                "api_version": 36.0,
                "is_sandbox": true,
                "workspace": "C:/workspace/huangxy2/"
            }
        }
    `

    Usage

    Run SOQL/Run Tooling api

    Select your SOQL, [SFDC-XY] -> [SFDC SOQL] -> [SOQL Query]/[Tooling Query] and run!

    Run SOQL

    SFDC Object Descript, Save as Excel

    Path: [SFDC-XY] -> [SFDC Object]

    SFDC Object

    SFDC DataViewer

    Path: [SFDC-XY] -> [SFDC Dataviewer]

    SFDC Object

    Create Test Code

    Open your apex code, [SFDC-XY] -> [SFDC Code Creator] -> [Create Test Code] and you can auto creat your apex test class!!

    Create Test Code

    ApexController , Viewer , TestClass Quick Jump

    Right Click, and find the click!

    Controller_VF_Jump

    Define your login browser

    Add your browsers setting as below

    `    // Add your browser which you like!

    // examle:
    // "firefox":"Path of firefox!",
    // "Edge":"Path of Edge", or another
    "browsers":
    {
        "chrome": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
        "IE": "C:\\Program Files\\Internet Explorer\\iexplore.exe"
    },
    

跨域请求Https

カスタムドメイン:あなたのコミュニティで既存のHTTPS証明書を使用

https://help.salesforce.com/htviewsolution?id=000232390&language=en_US&siteLang=en_us

HTTPS 中双向认证SSL 协议的具体过程

http://blog.csdn.net/zyw_anquan/article/details/7829053

OpenSSL

http://slproweb.com/products/Win32OpenSSL.html

http://blog.csdn.net/boss666666/article/details/10284649

http://blog.csdn.net/mycoolx/article/details/6730435

http://rms-digicert.ne.jp/howto/csr/csr_apache.html

http://blog.csdn.net/kamouswjw/article/details/39050995

http://www.cnblogs.com/vincentfu/p/5475248.html

http://blog.chinaunix.net/uid-174325-id-3563721.html

自签名需要请求HPPTS的私钥,目前除了花钱认证未找到解决方案。

客户端对下载的文件的处理,除了ActiveXObject还有其他解决方案吗?

【Salesforce】地理位置情報項目を使って周辺検索 GMaps

apex

<apex:page standardController=”Account” extensions=”GoogleMapCtrl”>

<head>

<script type=”text/javascript” src=”//maps.google.com/maps/api/js?sensor=false”></script>

<script type=”text/javascript” src=”https://hpneo.github.io/gmaps/gmaps.js"></script&gt;

<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script&gt;

<script type=”text/javascript”>

var map;

$(document).ready(function(){

createMap();

});

function createMap(){

map = new GMaps({

div: “#map-02”,

lat: “{!Account.BillingLatitude}”,

lng: “{!Account.BillingLongitude}”,

zoom: 11

});

var marks = {!jsonStr};

for (var i in marks) {

addMarker(map,marks[i]);

}

// 対象住所

map.addMarker({

lat: “{!Account.BillingLatitude}”,

lng: “{!Account.BillingLongitude}”,

icon: “{!$Resource.marker_green}”,

title: “{!Account.Name}”,

infoWindow: {

content: “{!Account.BillingState}{!Account.BillingCity}{!Account.BillingStreet}”

}

});

}

function addMarker( map,mark){

map.addMarker({

lat: mark.lat,

lng: mark.lng,

title: mark.title,

infoWindow: {

content: mark.content

}

});

}

</script>

</head>

<apex:form id=”frm”>

<apex:pageBlock >

<apex:outputpanel >

<apex:pageBlockSection >

<apex:pageBlockSectionItem >

<div class=”gmaps”>

<div id=”map-02” style=”width: 990px;height: 400px”></div>

</div>

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

<apex:pageBlockSection >

<apex:pageBlockSectionItem labelStyle=”text-align:left”>

<apex:outputpanel >

<apex:commandButton action=”{!doZoomPuls}” value=”+” id=”pulsButton” style=”width:40px; font-weight:bold” />

<apex:commandButton action=”{!doZoomMinus}” value=”-“ id=”minusButton” style=”width:40px;font-weight:bold”/>

<apex:outputText value=”検索範囲: “ />

<apex:inputText id=”dist” value=”{!findDistance}” style=”width:40px;” />

<apex:outputText value=” (km)” />

<apex:commandButton action=”{!getMapsInfos}” value=”検索” id=”searchBtn” style=”width:40px;”/>

</apex:outputpanel>

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

</apex:outputpanel>

<apex:outputpanel >

<apex:pageBlockSection >

<apex:pageBlockSectionItem >

<apex:pageBlockTable value=”{!mapDtoList}” var=”rec”>

<apex:column Style=”width:700px”>

<apex:facet name=”header”>隣接住所</apex:facet>

<apex:outputlink value=”/{!rec.id}” target=”_blank”>

<apex:outputLabel value=”{!rec.content}”/>

</apex:outputlink>

</apex:column>

<apex:column Style=”width:100px”>

<apex:facet name=”header”>距離(km)</apex:facet>

<apex:outputText value=”{!rec.calcDist}”/>

</apex:column>

</apex:pageBlockTable>

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

</apex:outputpanel>

</apex:pageBlock>

</apex:form>

</apex:page>
apex

public class GoogleMapCtrl {
public Account acc;
// 検索範囲
public decimal findDistance {get;set;}
public decimal zoom {get;set;}
public string jsonStr {get;set;}
public list<mapDto> mapDtoList {get; set;}
public GoogleMapCtrl(ApexPages.StandardController controller) {
if(findDistance == null){
this.findDistance = 10;
}
if(zoom == null){
zoom = 12;
}
list<string> field = new list<string>();
field.add(‘BillingLatitude’);
field.add(‘BillingLongitude’);
controller.addFields(field);
this.acc = (Account)controller.getRecord();
getMapsInfos();
}
/*
*マップ情報を取得
*/
public PageReference getMapsInfos(){
system.debug(‘========findDistance===========’+findDistance);
decimal lat = acc.BillingLatitude;
decimal lng = acc.BillingLongitude;
string query = ‘’;
query = ‘SELECT ‘;
query += ‘id’;
query += ‘,Name’;
query += ‘,BillingLatitude’;
query += ‘,BillingLongitude’;
query += ‘,BillingStreet’;
query += ‘,BillingPostalCode’;
query += ‘,BillingCity’;
query += ‘,BillingState’;
query += ‘,BillingCountry’;
query += ‘,BillingAddress’;
query += ‘,DISTANCE( BillingAddress, GEOLOCATION(‘+lat+’,’+lng+’), ‘+ ‘\’’ +’km’ +’\’’ +’) DIC ‘;
query += ‘FROM ‘;
query += ‘Account ‘;
query += ‘WHERE ‘;
query += ‘DISTANCE( BillingAddress, GEOLOCATION(‘+lat+’,’+lng+’), ‘+ ‘\’’ +’km’ + ‘\’’+’) <’ + string.valueof(findDistance);
query += ‘ and BillingLongitude !=null and BillingLatitude != null and BillingState !=null’;
query += ‘ and id !=’ + ‘\’’ + acc.id +’\’’;
query += ‘ Order by ‘;
query += ‘ Distance(BillingAddress, GEOLOCATION(‘+lat +’,’ + lng +’),’ + ‘\’’+’km’+’\’’+’)’;
system.debug(‘======query========’+query);
List<Account> nearAccountList = DataBase.query(query);
/*
List<Account> nearAccountList = [SELECT
id,
Name,
BillingLatitude,
BillingLongitude,
BillingStreet,
BillingPostalCode,
BillingCity,
BillingState,
BillingCountry ,
BillingAddress,
DISTANCE( BillingAddress, GEOLOCATION(:lat, :lng), ‘km’ ) DIC
FROM
Account
WHERE
Distance(BillingAddress, GEOLOCATION(:lat, :lng), ‘km’) < :findDistance
and BillingLongitude !=null and BillingLatitude != null and BillingState !=null
and id != :acc.id
Order by
Distance(BillingAddress, GEOLOCATION(:lat, :lng), ‘km’)
];
*/
this.mapDtoList = new list<mapDto>();
for(Account item : nearAccountList){
mapDto dto = new mapDto();
dto.id = item.id;
dto.title = item.Name;
dto.lat = item.BillingLatitude;
dto.lng = item.BillingLongitude;
dto.BillingState = item.BillingState;
dto.BillingCity = item.BillingCity;
dto.BillingStreet = item.BillingStreet;
dto.content = dto.getContent();
dto.calcDist = roundNumber((decimal)item.get(‘DIC’ ),2);
this.mapDtoList.add(dto);
}
this.jsonStr = JSON.serialize(this.mapDtoList);
system.debug(‘======jsonStr========’+jsonStr);
return null;
}
public void doZoomPuls(){
this.findDistance +=0.5;
getMapsInfos();
}
public void doZoomMinus(){
this.findDistance -=0.5;
getMapsInfos();
}
public class mapDto{
public String title {get;set;}
public String content {get;set;}
public decimal lat {get;set;}
public decimal lng {get;set;}
public decimal calcDist {get;set;}
public string BillingState {get;set;}
public string BillingCity {get;set;}
public string BillingStreet {get;set;}
public string id {get;set;}
public mapDto(){
this.id =’’;
this.title = ‘’;
this.content = ‘’;
this.lat = 0;
this.lng = 0;
this.BillingState = ‘’;
this.BillingCity = ‘’;
this.BillingStreet = ‘’;
this.calcDist =0;
}
public string getContent(){
return this.content = this.BillingState + this.BillingCity + this.BillingStreet;
}
}
//四捨五入
public Decimal roundNumber(Decimal roundNumber , Integer decimalPlace)
{
if(roundNumber != null)
{
return roundNumber.setScale(decimalPlace, RoundingMode.HALF_UP);
}
else
{
return 0 ;
}
}

}

Read More

Salesforce标准Object和Prefixkey

レコード ID プレフィックスデコーダ


























































































































































































































































































































































































































































































































































































































































































































































































































































































































エンティティプレフィックス
ACCOUNT(取引先)‘001’
QUOTE‘0Q0’
NOTE‘002’
CONTACT(取引先責任者)‘003’
USERS‘005’
OPPORTUNITY(商談)‘006’
ACTIVITY(活動)‘007’
OPPORTUNITY_HISTORY‘008’
FORECAST_ITEM‘00A’
FILTER‘00B’
DELETE_EVENT‘00C’
ORGANIZATION(組織)‘00D’
USER_ROLE‘00E’
QUEUE‘00G’
GROUPS‘00G’
PARTNER‘00I’
OPPORTUNITY_COMPETITOR‘00J’
OPPORTUNITY_CONTACT_ROLE‘00K’
CUSTOM_FIELD_DEFINITION‘00N’
REPORT(レポート)‘00O’
ATTACHMENT‘00P’
LEAD(リード)‘00Q’
IMPORT_QUEUE‘00S’
TASK(ToDo)‘00T’
EVENT(行動)‘00U’
EMAIL_TEMPLATE‘00X’
EMAIL_TEMP‘00Y’
COMMENTS‘00a’
CUSTOM_RESOURCE_LINK‘00b’
TRAINING‘00c’
PROFILE‘00e’
MH_BLUESHEET‘00f’
MH_GOLDSHEET‘00g’
LAYOUT‘00h’
PRICEBOOK_MAPPING‘00i’
PRICEBOOK_ENTRY_MAPPING‘00j’
OPPORTUNITY_LINEITEM‘00k’
FOLDER‘00l’
EMAIL_ATTACHMENT_LOOKUP‘00m’
EMAIL_ATTACHMENT_ARCHIVE‘00n’
LINEITEM_SCHEDULE‘00o’
USER_TEAM_MEMBER‘00p’
OPP_TEAM_MEMBER‘00q’
ACC_SHARE‘00r’
ACC_SHARE_DEFAULT‘00s’
OPP_SHARE‘00t’
OPP_SHARE_DEFAULT‘00u’
CAMPAIGN_MEMBER‘00v’
PAYMENT_APPLICATION‘00w’
BILLED_PRODUCT‘00x’
PURCHASE_RULE‘00y’
PURCHASE_RULE_ENTRY‘00z’
CASE_SOLUTION‘010’
GROUP_MEMBER‘011’
RECORD_TYPE‘012’
RECORD_TYPE_PICKLIST‘013’
PROFILE_RECORD_TYPE‘014’
DOCUMENT‘015’
BRAND_TEMPLATE‘016’
ENTITY_HISTORY‘017’
EMAIL_STATUS‘018’
BUSINESS_PROCESS‘019’
BUSINESS_PROCESS_PICKLIST‘01A’
LAYOUT_SECTION‘01B’
LAYOUT_ITEM‘01C’
PROFILE_LAYOUT‘01G’
MAILMERGE_TEMPLATE‘01H’
CUSTOM_ENTITY_DEFINITION‘01I’
PICKLIST_MASTER‘01J’
CURRENCY_TYPE‘01L’
ACC_TEAM_MEMBER‘01M’
ACTIVE_CONTENT‘01N’
USER_UI_CONFIGURATION‘01O’
PROFILE_TAB_CONFIGURATION‘01P’
WORKFLOW_RULE‘01Q’
RULE_FILTER‘01R’
RULE_FILTER_ITEM‘01S’
RULE_FILTER_ACTION‘01T’
ACTION_ASSIGN_ESCALATE‘01U’
ACTION_TASK‘01V’
ACTION_EMAIL‘01W’
ACTION_EMAIL_RECIPIENT‘01X’
CAMPAIGN_MEMBER_STATUS‘01Y’
DASHBOARD(ダッシュボード)‘01Z’
DASHBOARD_COMPONENT‘01a’
FILTER_ITEM‘01b’
FILTER_COLUMN‘01c’
FOLDER_GROUPS‘01d’
PICKLIST_SET‘01e’
WEBEX_MEETING‘01f’
API_QUERY‘01g’
TRANSLATION‘01h’
TRANSLATION_USER‘01i’
TRANSLATION_VALUE‘01j’
PROFILE_FLS_ITEM‘01k’
ACTION_RESPONSE‘01l’
BUSINESS_HOURS‘01m’
CASE_SHARE‘01n’
LEAD_SHARE‘01o’
CUSTOM_TAB_DEFINITION‘01r’
PRICEBOOK2‘01s’
PRODUCT2‘01t’
PRICEBOOK_ENTRY‘01u’
PRICEBOOK_SHARE‘01v’
OPP_UPDATE_REMINDER‘01w’
OPP_UPDATE_REMINDER_STATS‘01x’
CASE_SHARE_DEFAULT‘01y’
CASE_ESCALATION‘01z’
EVENT_ATTENDEE‘020’
QUANTITY_FORECAST‘021’
FISCAL_YEAR_SETTINGS‘022’
APP_CALENDAR‘023’
APP_CALENDAR_SHARING‘024’
LIST_LAYOUT_ITEM‘025’
PERIOD‘026’
REVENUE_FORECAST‘027’
OPPORTUNITY_OVERRIDE‘028’
LINEITEM_OVERRIDE‘029’
LEAD_SHARE_DEFAULT‘02A’
LABEL_DEFINITION‘02B’
LABEL_DATA‘02C’
CASES_HISTORY2‘02D’
HELP_SETTING‘02E’
CUSTOM_FIELD_MAP‘02F’
MH_GOLD_PROGRAM‘02H’
MH_GOLD_INFORMATION‘02I’
MH_GOLD_CONTACT‘02J’
MH_GOLD_ACTION‘02K’
MH_CUSTOMER_CRITERION‘02L’
MH_GREENSHEET‘02M’
MH_GREEN_GIVE_INFO‘02N’
MH_GREEN_GET_INFO‘02O’
MH_CONTACT_ROLE‘02P’
MH_INFORMATION‘02Q’
USER_PREFERENCE‘02R’
HTML_COMPONENT‘02S’
CUSTOM_PAGE‘02T’
CUSTOM_PAGE_ITEM‘02U’
PAGE_COMPONENT‘02V’
CUSTOM_PAGE_PROFILE‘02X’
USER_COMPONENT_DATA‘02Y’
ACCOUNT_CONTACT_ROLE‘02Z’
CONTRACT_CONTACT_ROLE‘02a’
COMPONENT_RESOURCE_LINK‘02b’
DIVISION‘02d’
DIVISION_WORKFLOW_RULE‘02e’
DELEGATE_GROUP‘02f’
DELEGATE_GROUP_MEMBER‘02g’
DELEGATE_GROUP_GRANT‘02h’
ASSET‘02i’
PROFILE_ENTITY_PERMISSIONS‘02j’
LIST_LAYOUT‘02k’
OUTBOUND_QUEUE‘02l’
CUSTOM_INDEX‘02m’
CATEGORY_NODE‘02n’
CATEGORY_DATA‘02o’
DIV_TRANSFER_EVENT‘02p’
LAYOUT_ITEM_COLUMN‘02q’
OPPORTUNITY_ALERT‘02r’
EMAIL_MESSAGE‘02s’
EMAIL_ROUTING_ADDRESS‘02t’
TAB_SET‘02u’
TAB_SET_MEMBER‘02v’
LOGIN_IP_RANGE‘02w’
LOGIN_HOURS‘02x’
REPORT_AGGREGATE‘02y’
REPORT_COLOR_RANGE‘02z’
PROFILE_TAB_SET‘030’
USER_TAB_SET_MEMBER‘031’
ACC_TERRITORY_RULE‘032’
PROJECT‘033’
PROJECT_MEMBER‘034’
SELF_SERVICE_USER‘035’
JOB_QUEUE‘036’
REPORT_COLUMN‘037’
REPORT_FILTER_ITEM‘038’
REPORT_BREAK‘039’
DEPENDENT_PICKLIST‘03a’
PACKAGE_EXPORT‘03b’
LAYOUT_RIGHT_PANEL‘03c’
CUSTOM_SETUP_DEFINITION‘03e’
CUSTOM_SETUP‘03f’
REPORT_PARAM‘040’
ACC_TERRITORY_ASSIGN‘041’
ACC_TERR_ASSIGN_RULE_ITEM‘042’
OUTBOUND_FIELD‘043’
USER_TERRITORY‘04S’
TERRITORY‘04T’
DNB_ACCOUNT_MAPPING‘04U’
DNB_FIELD‘04V’
REVENUE_FORECAST_HISTORY‘04W’
QUANTITY_FORECAST_HISTORY‘04X’
CONTENTVERSION‘068’
CONTENTDOCUMENT‘069’
ENTITY_PERMISSION‘110’
SFDC_PARTNER‘204’
SFDC_DIVISION‘208’
CASES‘500’
SOLUTION‘501’
BILLING_DIVISION‘600’
BILLING_ORDER‘601’
CURRENCY‘602’
PLAN‘604’
PRODUCT‘605’
BILLING_ORDER_ITEM‘606’
PLAN_PRODUCT‘607’
CAMPAIGN(キャンペーン)‘701’
FIELD_HISTORY‘737’
UI_STYLE_DEFINITION‘766’
UI_STYLE‘777’
CONTRACT(契約)‘800’
ORDERS(注文)‘801’
ORDER_ITEM‘802’
INVOICE‘803’
INVOICE_ITEM‘804’
PAYMENT‘805’
APPROVAL‘806’
URI_BLOCK_RULE‘807’
CUSTOM_ENTITY_DATA‘a00’
PERMISSIONSET‘0PS’

Salesforce通过Apex获取API名

//Apex
public class Apiget{

 //表示用リストクラス
 public List<apiname> apinameList{get;set;}

 //データ格納用クラス
 class apiname{
 public String objectLabel{get;set;}
 public String objectName{get;set;}
 public String objectkeyPrefix{get;set;}
 }

 //コンストラクタ
 public Apiget(){

 //全オブジェクト情報取得
 MAP<string,Schema.SObjectType> sobMap =schema.getGlobalDescribe();
 apinameList = new List<apiname>();
 for(String sobStr : sobMap.keySet()){
 apiname apnameclass = new apiname();
 Schema.SObjectType sobType = sobMap.get(sobStr);
 Schema.DescribeSObjectResult sobRes = sobType.getDescribe();
 apnameclass.objectLabel = sobRes.label;
 apnameclass.objectName = sobRes.name;
 apnameclass.objectkeyPrefix = sobRes.keyPrefix;

 //カスタムオブジェクトは除く
 if(!sobRes.custom)apinameList.add(apnameclass);
 }
 }
}

SFDC get Exception from Trigger

Salesforce中如何破获Trigger的Exception呢??

Database.Update返回的的结果,判断是否更新成功,然后处理异常信息。
通过AddError就可以处理系统异常,替换成需要的信息。

 if(updateList.size() > 0) {
Database.SaveResult[] lsr = Database.Update(updateList, false);
for(Database.SaveResult sr : lsr){
if (!sr.isSuccess()) {
System.debug(LoggingLevel.ERROR, ‘* sr: ‘ + sr);
Paymentc payment = new Paymentc(id=sr.getId());
for(Database.Error err : sr.getErrors()) {
payment.addError(err.getMessage());
}
}
}
}

 


Tip From web

SFDC:Apexトリガーのエラー判定について

Apexトリガーのafter triggerのタイミングでDML処理を実行した際に入力規則によるエラーが発生すると次のようなエラーメッセージが表示されてしまいます。

ちょっとした入力漏れなどで入力規則に引っかかってしまった時に、このようなエラーメッセージが表示されてしまうとちょっと残念な感じになってしまいます。

 

この問題を回避するにはただUpdateを行うのではなく、Database.UpdateのようにDatabase ClassをつかったDML処理を実行することで回避ができます。

 

Database ClassによるDML処理はExceptionエラーが発生したときでも処理を中断せずにDatabase.Saveresultというデータ型に値を保持してくれています。

 

Database.Saveresultでは「isSuccess()」でエラーの有無を確認することができ、Database.Errorでエラーの情報を取得することが可能になります。

 

次のような感じでDatabase.Saveresultのリストをループしながらエラーレコードをチェックしていき、エラーレコードに対してはaddErrorでエラーメッセ―ジを表示させるようにします。

 

Database.ErrorのgetMessage()をつかうことで入力規則のエラーメッセージのみを画面に表示させることができます。

Salesforce PDF

<apex:page renderAs="pdf" sidebar="false" showHeader="false" controller="IBMerInfoController" applyHtmlTag="false" applyBodyTag="false" id="pdfPage">
 <html>
 <head>
 <style>

 body {
 font-family: Arial Unicode MS; 
 font-size:3mm;
 letter-spacing:0;
 margin: 0mm;

}

 @page {
 size: 11.69in 8.27in; /* A4 縦サイズ */
 margin-top: 5mm;
 margin-bottom: 0mm;
 margin-left: 2mm;
 margin-right: 2mm;
 }

 .breakline {
 page-break-after: always;
 }

 </style>
 </head>
 <body>
 <!-- ここに表示内容 -->
 <table width="100%" >
 <apex:variable var="width" value="69.3mm" />
 <apex:variable var="height" value="38mm" />

<apex:repeat value="{!tableElement}" var="row">
 <tr>
 <apex:repeat value="{!row.cellLst}" var="td">
 <td >
 <table style="table-layout:fixed;" width="{!width}" height="{!height}" border="1px;" >
 <tr>
 <td style="width: {!width}; height:{!height}" >
 <apex:outputPanel rendered="{!td.rendered}">
<div align="center">{!td.contact.Name} 様</div>
 </apex:outputPanel>
 </td>
 </tr>
 </table>
 </td>
 </apex:repeat>
 </tr>
 <apex:outputPanel layout="none" rendered="{!(MOD(row.rowCount, 5) == 0 && tableElement.size != row.rowCount)}" >
 <div id="breakline" class="breakline" ></div>
 </apex:outputPanel>
 </apex:repeat>
 </table>
 </body>
</html>

</apex:page>

关于PDF, 如果设置applyHtmlTag="false", 就不支持HTML标签,需要用\n换行, 换行逻辑
/**
 * <br/>タグをエスケープ。
 */
 private static final String BR_TG_ESCAPE = '%%br%%';
 /**
 * タグを表す正規表現。
 */
 private static final String REGEX_TAG = '<.+?>';
 /**
 * <br>タグ。
 */
 public static final String BR_TG = '<br>';
 /**
 * <br/>タグ。
 */
 public static final String BR_SLASH_TG = '\n';
 /**
 * 空白を定義。
 */
 public static final String STRING_NONE = '';
 /**
 * \n(改行)を定義。
 */
 public static final String NEW_LINE_CHARACTER = '\n';
 /**
 * 【$】を定義。
 */
 public static final String DOLLAR_CHARACTER = '$';

 public static final Integer MAX_BYTE = 60;

/**
 * 閾値を超えたら<br/>を挿入する。
 *
 * 1,<br>タグを「%%br%%」に置換する
 * 2,タグを除去する
 * 3,改行(\n)を<br/>を着換える
 * 4,置換した「%%br%%」を<br/>に置換する
 * 5,文字列の長さをバイト数で計算し閾値を超えたら<br/>を追加する
 *
 * @param targetString <br/>タグを入れる文字列
 * @param maxByte <br/>を入れるバイト数
 * @return String 加工した文字列
 */
 public static String convertString(final String targetString) {
 Integer maxByte = MAX_BYTE;

//加工した文字列保持
 String convertStr = STRING_NONE;

if (targetString != null) {

//<br>がある場合は置き換える
 String targetStr = targetString.replaceAll(BR_TG, BR_TG_ESCAPE);
 targetStr = targetStr.replaceAll(BR_SLASH_TG, BR_TG_ESCAPE);
 //タグ除去
 targetStr = targetStr.replaceAll(REGEX_TAG, STRING_NONE);
 //改行を<br/>に変換
 targetStr = targetStr.replaceAll(
 NEW_LINE_CHARACTER,
 BR_SLASH_TG
 );

//置き換えた改行を<br/>に変換
 targetStr = targetStr.replaceAll(BR_TG_ESCAPE, BR_SLASH_TG);
 //<br/>でsplit
 String[] strList = targetStr.split(BR_SLASH_TG);

//一行の文字数
 Integer lineLen = 0;

//<br/>単位 一ライン
 for (String line : strList) {

//一行のバイト数の合計値
 Integer sum = 0;
 //インデックス
 Integer index = 0;
 //一行の文字数取得する
 lineLen = line.length();

//一文字ずつバイト数をチェックする
 for (Integer i = 0; i < lineLen; i++) {

//一文字取得
 String one = line.substring(i, (i + 1));
 //一文字バイト数計算
 Integer oneSize = getBytes(one);
 //合計
 sum += oneSize;

//MAXを超えた場合
 if (sum > maxByte) {
 //クリア
 sum = 0;
 //改行を追加
 convertStr += line.substring(index, (i + 1))
 + BR_SLASH_TG;
 index = i + 1;
 }
 }
 //改行を追加
 convertStr += line.substring(index, (line.length()))
 + BR_SLASH_TG;
 }
 }

//最後尾のbrを外す
 convertStr =
 convertStr.replaceAll(
 BR_SLASH_TG + DOLLAR_CHARACTER,
 STRING_NONE
 );

return convertStr;
 }

/**
 * 文字のバイト数を取得。
 *
 * @param strings 文字
 * @return Integer バイト数
 */
 private static Integer getBytes(final String strings) {
 return Blob.valueOf(strings).size();
 }