Skip to main content 欢迎参加 3 月 5 日至 6 日在旧金山举行的 TDX AI 代理时代开发者大会,或通过 Salesforce+ 参与。立即注册

Hi Folks,

I have two objects:

ParentObject__c (Parent record)

ChildObjetc__c (Child Record)

The relationship between them is master-detail.

I need to create a visualforce page to be able to create a child record, that is, when accessing the details of the parent record, have a custom button that will call the visualforcepage to be able to create a child record, with the parent record id.

Does anyone have any idea code to help me?
2 个回答
  1. 2019年6月10日 20:34
    Hi Luciano,

    If you just want to create child record from parent detail page, I would suggest you to use quick actions instead of a custom button and visualforce page, unless you have some other requirements to go with custom page solution which you have not stated here.

    Follow below steps to achieve this:

    1. Go to parent object from object manager and click on " Buttons Links and Actions" Link.
    2. Then create a new action with action type = "Create a new record". Select target object as your child object and then define other properties.
    3. Then select the fields of child object that you want on the record creation page. Click save.
    4. Go to the page layout of parent object and add the newly created action to quick actions bar.

    Please like and mark resolved if this helps.

     
0/9000