0

Salesforce でカスタム ボタン オーバーライドを作成したいと考えています。削除ボタンをオーバーライドして、削除するのではなく、レコードの種類を変更したいだけです。

私のカスタムオブジェクトはAbsence__c

4

2 に答える 2

0

あなたの最善の策は、コントローラーの拡張機能と既存の [削除] ボタンのオーバーライドだと思います。

<apex:Page action="changeRTRedirect"
    standardController="Absence__c" extensions="DeleteOverrideExtension">
</apex:page>

public class DeleteOverrideExtension {
    private SObject record;

    public DeleteOverrideExtension(ApexPages.StandardController controller) {
        record = controller.getRecord();
    }

    public PageReference changeRTRedirect() {
        record.RecordTypeId = '[YOUR NEW RT ID]';
        update record;
        //where do you want to send users now, maybe the Absence__c tab?
        return Page.MyPageHere;
    }
}
于 2012-07-03T06:54:47.200 に答える
0

これを試して:

ページレイアウト編集し、「削除」ボタンを削除し、「削除」という名前のカスタムボタンを作成し、javascript をボタンの動作に設定するだけです。最後に、そのボタンをページ レイアウトに追加します。

これは、カスタム ボタンのサンプル コードです。

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}

var AbsenceUpdate = new sforce.SObject("Absence__c");

AbsenceUpdate.Id='{! Absence__c.Id  }';
AbsenceUpdate.RecordTypeId = '{new record type id}';

if(AbsenceUpdate!=null)
{
    try
    {
     updateOpp = sforce.connection.update([AbsenceUpdate]);
      window.location.reload();
    }
    catch(e)
    {
        alert('error : ' + e);
    }
}
于 2012-06-29T14:05:29.293 に答える