Memos About Salesforce

Salesforceにハマってたこと!

フォームにカスタムのフィールド・タブの追加方法

今回出したソースの例の中にタブ・フィールド・サブタブの追加例は全部記載している。

注意点はタブであろうがフィールドであろうが サブタブであろうが どっちも引数1はcustpageがないとエラーになる。 custpageプラス任意の意味のある英文字でいいと思う。 カスタマイズものなら、custpage_が必須だから。

//Define the user event beforeLoad function 
function tabsToSalesOrder(type, form) { 
    //Define the values of the beforeLoad type argument
    if (type == 'edit' || type == 'view') { 
        //タブ例、フォームに追加 
        var sampleTab = form.addTab('custpage_sample_tab', 'Sample Tab');
        //フィールド例、フォームに追加 
        var newFieldEmail = form.addField('custpage_field_email', 'email', 'Alt Email', null, 'custpage_sample_tab');
        //Add a second field to the new tab 
        var newFieldText = form.addField('custpage_field_text', 'textarea', 'Details', null, 'custpage_sample_tab');
        //サブタブ例、タブに追加 
        var sampleSubTab = form.addSubTab('custpage_sample_subtab', 'Sample Subtab', 'custpage_sample_tab');
        //Add a select field to the subtab 
        var newSubField = form.addField('custpage_sample_field', 'select', 'My Customers', 'customer', 'custpage_sample_subtab');
        //Add a second subtab to the first tab 
        var sampleSubTab = form.addSubTab('custpage_sample_subtab2', 'Second Sample Subtab', 'custpage_sample_tab');
        //Add a field to the second subtab 
        var newSubField = form.addField('custpage_sample_field2', 'select', 'My Employees', 'employee', 'custpage_sample_subtab2');
    }
}