2011年1月31日月曜日

メールに添付ファイル

Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('attachment.pdf');
PageReference pdf = Page.attachmentPDF;
pdf.getParameters().put('id',(String)account.id);
pdf.setRedirect(true);
Blob b = pdf.getContent();
efa.setBody(b);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});

2011年1月27日木曜日

sforce.apex.execute

Apex class→
global class executeAnonymous {
webService static integer getContactCount(String accountId) {
return [select count() from Contact where AccountId =:accountId];
}
}
---------------
Custom ButtonのJavaScript→
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")};
alert(sforce.apex.execute("executeAnonymous","getContactCount",{accountId:'{!Account.Id}'}));

2011年1月26日水曜日

System.Schedule

global with sharing class Cron implements Schedulable{
public List results{get;set;}
public void doStart(){
System.schedule('ScheduledApex','0 0 0 3 9 ? 2022', new Cron());
}
public void doRefresh(){
results = [SELECT id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger];
}
global void execute(SchedulableContext ctx) {
System.debug('This is cron log.');
}
}
----------------------------
<apex:page controller="Cron">
<apex:form
>
 <apex:commandButton value="Start"
action="{!doStart}"/><br/>
 <apex:commandButton
value="Refresh" action="{!doRefresh}"/>
 <apex:pageBlock
title="Cron Trigger" id="theCronTrigger">
   
<apex:pageBlockTable value="{!results}" var="r"
rendered="{!NOT(ISNULL(results))}">
     
<apex:column value="{!r.id}"/>
     
<apex:column
value="{!r.CronExpression}"/>
     
<apex:column
value="{!r.TimesTriggered}"/>
     
<apex:column value="{!r.NextFireTime}"/>
   
</apex:pageBlockTable>
 
</apex:pageBlock>
</apex:form>
</apex:page>

自分のドメインを利用

1.設定→開発→サイト→編集→カスタム Web アドレスに自分ドメイン「www.appforce.info」を入力する。
2.自分のドメイン管理情報に下記レコードを追加して、
ホスト名:www
TYPE:CNAME
VALUE:デフォルト Web アドレス「free-12415f14c3a-124e539428a-12ce49ac4b9.force.com」

Google分析追跡

<site:googleAnalyticsTracking/>

2011年1月25日火曜日

VFPageソースを取得する

public string pageContent{get{return Page.VFPageName.getContent().toString();}set;}

<apex:outputText value="{!pageContent}" id="pageContent"/>

2011年1月21日金曜日

標準レイアウトの同セクションに1列と2列同時存在方法

標準レイアウトに下記画面イメージの実現方法

新しセクションを追加して、「Section Name」はブランク「 」設定して、「Detail Page」と「Edit Page」選択しない。長い表示項目をこのセクションに追加する。

取引先の親取引先非表示

取引先標準レイアウトに親取引先項目を削除できない。
表示しない方法:
設定→セキュリティのコントロール→項目アクセス許可→取引先→項目ごとの参照→項目:親取引先→システム管理者→非表示

標準オブジェクトタブ名変更

設定→カスタマイズ→タブ名と表示ラベル→タブと表示ラベルの名称変更→取引先の編集
標準項目の表示ラベルも変更可能。