3
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 5 years have passed since last update.

【Salesforce】オブジェクトの標準newアクション呼び出し方

3
Last updated at Posted at 2020-03-25
Page 1 of 5

【Salesforce】オブジェクトの標準newアクション呼び出し方

$actionから呼び出し

<apex:outputLink value="{!URLFOR($Action.Account.New)}">
    Create New Account
</apex:outputLink>

pageReference Typesから呼び出し


// Navigates to a new account object using these default field values.
//{
//    Name: "Salesforce, #1=CRM",
//    OwnerId: "005XXXXXXXXXXXXXXX",
//    AccountNumber: "ACXXXX",
//    NumberOfEmployees: 35000,
//    CustomCheckbox__c: true
//}
{
    type: "standard__objectPage",
    attributes: {
        objectApiName: "Account",
        actionName: "new"
    },
    state: {
        defaultFieldValues = "AccountNumber=ACXXXX,CustomCheckbox__c=true,Name=Salesforce%2C%20%231%3DCRM,NumberOfEmployees=35000,OwnerId=005XXXXXXXXXXXXXXX",
        nooverride: "1"
    }
}

URLから呼び出し

url
//    AccountNumber: "ACXXXX",
//    CustomCheckbox__c: "true",
//    Name: "Salesforce, #1=CRM",
//    OwnerId: "005XXXXXXXXXXXXXXX",
//    AccountNumber: "ACXXXX",
//    NumberOfEmployees: 35000,
//    CustomCheckbox__c: true
<a herf="https://yourdomainname.lightning.force.com/lightning/o/Opportunity/new?defaultFieldValues=AccountNumber=ACXXXX,CustomCheckbox__c=true,Name=Salesforce%2C%20%231%3DCRM,NumberOfEmployees=35000,OwnerId=005XXXXXXXXXXXXXXX"/>

注意事項

  1. パラメータの渡し方

 pageReference TypesからやカスタムURLボタンから呼び出し場合、defaultFieldValuesでパラメータが渡られます。
 ※大文字小文字区分
2. レコードタイプの設定

 URLから呼び出し場合、
 二つ方法のうち、一つ方法が若干不具合がある。

  2.1. stateのdefaultFieldValues変数に設定する、画面は設定したレコードタイプの画面を使えますけど、タイトルは最初のレコードタイプの名前を表示される


    <a herf="https://yourdomainname.lightning.force.com/lightning/o/Opportunity/new?defaultFieldValues=RecordTypeId=<recordtypeid:15桁英数字>,…" />

  2.2. GETリクエストのパラメータとして設定する、タイトルの問題が解決できる

    <a herf="https://yourdomainname.lightning.force.com/lightning/o/Opportunity/new?recordTypeId=<recordtypeid:15桁英数字>&defaultFieldValues=…" />

 ※パラメータ名は大文字小文字区分、ご注意ください!!

参照

Visualforce 開発者ガイド⇒$action
Visualforce 開発者ガイド⇒$Action グローバル変数の有効な値
Lightning Aura Components Developer Guide(v48.0以降)
NavigationMixin to standard__objectPage passing recordType value
Spring 20 - Navigate to a Record’s Create Page with Default Field Values - How to pass the Recordtype id??

3
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
3
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?