{!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;
}
}