1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

salesforce vfページの参照画面に新規ボタン追加

Last updated at Posted at 2020-07-14

①カスタムボタンまたはカスタムリンク追加
image.png

{!REQUIRESCRIPT('/soap/ajax/46.0/connection.js')} 
{!REQUIRESCRIPT('/soap/ajax/46.0/apex.js')} 

var ret = sforce.apex.execute('ClassName','CreateObject',{}); 
location.href = ret;

②Apexクラス作成  3桁のPrefix取得

ClassName.cls
global class ClassName {
    webService static String CreateObject() {
        String prefix = CustomObject__c.sObjectType.getDescribe().getKeyPrefix();
        return URL.getSalesforceBaseUrl().toExternalForm() + '/' + prefix + '/e?&retURL=%2F' + prefix;
    }
}

③画面表示 新規ボタンをキリックして、新規画面へ遷移
image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?