[Salesforce]PDFファイルを作成して、Salesforceメールテンプレートに添付

PDFファイルを作成して、Salesforceメールテンプレートに添付

Visualforceメールテンプレ―ド:

<messaging:emailTemplate subject="test: {!relatedTo.name}" recipientType="Contact" relatedToType="Opportunity">

    <messaging:plainTextEmailBody >
        添付送付させていただきます。
        ご確認お願いいたします。
    </messaging:plainTextEmailBody>

    <messaging:htmlEmailBody >
    <html>
        <body>
            <p>添付送付させていただきます。</p>
            <p>ご確認お願いいたします。</p>
        </body>
    </html>
    </messaging:htmlEmailBody>

    <messaging:attachment renderAs="PDF" filename="Invoice.pdf">
        <c:OppAttachmentComponent opportunityId="{!relatedTo.Id}" opportunity="{!relatedTo}"/>
   </messaging:attachment>
</messaging:emailTemplate>

Component : OppAttachmentComponen

<apex:component controller="OppAttachmentComponentController" access="global" >
    <apex:attribute name="opportunityId" description="OpportunityId" assignTo="{!OpportunityId}" type="Id" />       

    test
    {!opportunity.Name}

</apex:component>

commponent controller : OppAttachmentComponentController

global class OppAttachmentComponentController {

    global String OpportunityId{ 
        get;
        set {
            UpdateContents2(value);
        } 
    }

     public void UpdateContents2(String OpportunityId) {

         if (OpportunityId != null) {
            List<Opportunity> oppList = [SELECT Id FROM Opportunity WHERE Id =:OpportunityId];

        }
    }

}

[Salesforce]JavaScript Remoting 要求の設定

JavaScript Remoting 要求の設定

要求のタイムアウト (ミリ秒単位)。デフォルトは 30,000 (30 秒) です。最大値は 120,000 (120 秒 = 2 分) です。120秒に設定方法例は以下です。

<script type="text/javascript">

    Visualforce.remoting.timeout = 120000; // Set timeout at page level

    function getRemoteAccount() {
        var accountName = document.getElementById('acctSearch').value;

        // This remoting call will use the page's timeout value
        Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.AccountRemoter.getAccount}',
            accountName, 
            handleResult
        );
    }

    function handleResult(result, event) { ... }
</script>

[Salesforce]カスタムアクション制限事項

カスタムアクション制限事項

https://developer.salesforce.com/docs/atlas.ja-jp.case_feed_dev.meta/case_feed_dev/case_feed_dev_guide_custom_publishers.htmアクションの選択および設定にページレイアウトエディタを使用することを選択した場合は、まずカスタムアクションを作成する必要があります。

  1. ケースのオブジェクト管理設定から、[ボタン、リンク、およびアクション] に移動します。
  2. [新規アクション] をクリックします。
  3. [カスタム Visualforce] を選択します。
  4. 作成した Visualforce ページを選択してから、アクションウィンドウの高さを指定します。(幅は固定です)。
  5. アクションの表示ラベルを入力します。これは、パブリッシャーでアクションについてユーザに表示されるテキストです。
  6. 必要に応じて、アクションの名前を変更します。
  7. アクションの説明を入力します。説明は、アクションの詳細ページと、[ボタン、リンク、およびアクション] ページのリストに表示されます。説明はユーザに表示されません。
  8. 必要に応じて、[変更アイコン] をクリックして、アクションに別のアイコンを選択します。このアイコンは、API を介してアクションを使用する場合にのみ表示されます。

[Salesforce][Reference url]Visualforceアクションヘッダー非表示

[Reference url]Visualforceアクションヘッダー非表示

<apex:page docType="html-5.0" standardController="Campaign"  extensions="testController" title="testCreate" showHeader="true" showQuickActionVfHeader="false" sidebar="false" id="testyCreate">

上記の、showQuickActionVfHeader="false"にすることで、アクションヘッダー非表示

[Salesforce]outputPanelのrendered属性

outputPanelのrendered属性

<apex:commandButton reRender="page1,page2" value="Search"/>
<br/>

<apex:OutputPanel id="page1">
	<apex:OutputPanel rendered="{!isDone}">
	<apexageBlock title="title1">
	   title1
	</apex:PageBlock>
	</apex:OutputPanel>
</apex:OutputPanel>


<apex:OutputPanel id="page2">
	<apex:OutputPanel rendered="{!NOT(isDone)}">
	<apex:PageBlock title="title2">
	   title2
	</apex:PageBlock>
	</apex:OutputPanel>
</apex:OutputPanel>

[Salesforce]ApexでawsへファイルDelete

ApexでawsへファイルDelete

    public Integer fileUpload(Attachment file){

        String attachmentBodyEncoded = EncodingUtil.base64Encode(file.Body);
        String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
        String key = awsAccessKey;
        String secret = awsSecretAccessKey;
        String bucketname = awsBucket;
        String host = awsService + '-' + awsReign + '.amazonaws.com'; 
        String method = 'DELETE';
        String fileNameEncoded	= EncodingUtil.urlEncode(file.Name, 'UTF-8');

        HttpRequest req = new HttpRequest();
        req.setMethod(method);
        req.setEndpoint('https://' + bucketname + '.' + host + '/' + bucketname + '/' + fileNameEncoded);
        req.setHeader('Host', bucketname + '.' + host);
        req.setHeader('Content-Length', String.valueOf(attachmentBodyEncoded.length()));
        req.setHeader('Content-Encoding', 'UTF-8');
        req.setHeader('Content-type', file.ContentType);
        req.setHeader('Connection', 'keep-alive');
        req.setHeader('Date', formattedDateString);
        req.setHeader('ACL', 'public-read-write');
        req.setBodyAsBlob(EncodingUtil.base64Decode(attachmentBodyEncoded));
         
        String stringToSign = 'DELETE\n\n' +
        file.ContentType + '\n' +
        formattedDateString + '\n' +
        '/' + bucketname + '/' + bucketname + '/' + fileNameEncoded;
         
        Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(secret));
        String signed = EncodingUtil.base64Encode(mac);
        String authHeader = 'AWS' + ' ' + key + ':' + signed;
        req.setHeader('Authorization',authHeader);
         
        Http http = new Http();
        HTTPResponse res = http.send(req);

        return res.getStatusCode();

    }

[Salesforce]Apexをスケジュール設定でApexクラスが検索されない件の対応

Apexをスケジュール設定でApexクラスが検索されない件の対応

検索されないケース

public class  SampleBatchSchedule implements Schedulable {
    public void execute(SchedulableContext sc) {
        SampleBatch batch = new SampleBatch();
        database.executebatch(batch);
    }
 }

検索されるケース

global class  SampleBatchSchedule implements Schedulable {
    public void execute(SchedulableContext sc) {
        SampleBatch batch = new SampleBatch();
        database.executebatch(batch);
    }
 }