- 25 May 2023
- 1 Minute to read
- Print
- DarkLight
Add a New Scenario action button
- Updated on 25 May 2023
- 1 Minute to read
- Print
- DarkLight
To add and enable a New Scenario action button, you must:
- Create a copy directive
- Create a Lightning component
- Create the action button
- Drop the action button on the object layout
- Add the action button to the Lightning record page
Create a copy directive
Go to Setup > Custom Code > Custom Metadata Types.
On the Copy Directive row, select Manage Records, then select New.
In the Copy Directive Name field, enter zdm_agreeScenarioDirective.
In the Copy Directive JSON field, define fields to be copied.
TipYou can use the JSON body of the Simple_PriceLookup_Copy directive and make necessary changes to it.
Select Save.
Create a Lightning component
Go to Developer Console > File > New > Lightning Component.
In the New Lightning bundle dialog, in the Name field, enter a custom name for your component.
Select Submit.
Replace the .cmp markup file with the following:
<aura:component access="global" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId"> <zpl:CreateScenarioModal copyDirectiveLabel="<Label of the Copy Directive>" recordId="{!v.recordId}"/> </aura:component>
Replace the value for the Label of the Copy Directive attribute with the label of the copy directive you created.
Save the component.
Create the New Scenario action button
- From the Setup interface in the customer's org, go to Object Manager and select your header object.
- In the Buttons, Links and Actions section, select New Action.
- In the Label and Name fields, enter New Scenario.
- From the Action Type dropdown, select Lightning Component.
- From the Lightning Component dropdown, select the name of the component you created in Create a Lightning component.
- In the Height field, specify 650px.
- Select Save.
Drop the action button on the object layout
- Go to Page Layouts for this object and select a layout.
- In the Mobile & Lightning Actions section, find the New Scenario action button.
- Drag it to the correct place in the layout.
- Select Save.
Add the action button to the Lightning record page
If the Lightning record page is using dynamic forms, you must add the action to the Lightning record page.