- 14 May 2024
- 3 Minutes to read
- Print
- DarkLight
Configure Copy action
- Updated on 14 May 2024
- 3 Minutes to read
- Print
- DarkLight
You can configure the Copy Lightning action and add it to your Agreement and Quote Lightning record page layouts. This enables users to copy an existing agreement or quote and use the copy as a starting point for a new agreement or quote.
When configured, the Copy button duplicates the agreement or quote's header information, line items, and sublines in one action.
Add the Copy action button
Add the Copy Lightning Action button to the Highlights Panel area of the Agreement and Quote Lightning record page layouts.
- From an existing Agreement or Quote page, select Setup, then select Edit Page.
- At the top of the central page layout area, select the Highlights Panel component to display its properties panel.
- In the properties panel, scroll down to the Assign Page Layouts section, then select the previewed page layout.
- In the page layout editor, in the palette area, select the Mobile & Lightning actions group.
- Move the Copy action button into the Salesforce Mobile and Lightning Experience Actions area of the page layout.
- Select Save.
The Copy action button works by looking for the Global copy configuration and the managed copy directive that is associated with the same object as the Copy button itself. For example, if you added the Copy button to your Quote Lightning record page layout, the button is associated with the zpl_PriceLookup_c object. When a user selects the Copy button on any existing quote, the system looks for the Global copy configuration and the managed copy directive named Simple_PriceLookup_Copy that is associated with the zpl_PriceLookup_c object, and then performs the copy acton as defined by those two custom metadata types.
Deal Manager managed packages include three default copy directives:
- Simple_Contract_Copy—Contract copy directive that works with the Copy button.
- Simple_PriceLookup_Copy—The zpl_PriceLookup_c copy directive that works with the Copy button.
- Simple_Deal_Copy—The zpl_Deal_c copy directive that works with the Copy button.
You can also configure a custom copy directive. For more information, read Configure custom copy directives.
Define the Global copy configuration
The Global copy configuration specifies which field values must never be copied from any agreement or quote. This could be, for example, CreatedByID and CreatedDate fields. In the new copy, you want these fields always to be populated with new system values.
- Go to Setup > Custom Code > Custom Metadata Types.
- On the Copy Configuration row, select Manage Records.
- For the Global copy configuration, select Edit.
- In the Copy Exclude Directive JSON field, specify a single fieldsToExclude array that lists all the fields common to the Contract, zpl_PriceLookup_c, and zpl_Deal_c objects that you want to exclude from every Copy action.
In the following step, you can define additional fields to exclude that are specific to the Contract, zpl_PriceLookup_c, and zpl_Deal_c objects.
Do this in the copy directive for each object.
JSON example for the Global copy configuration
{
"fieldsToExclude":[
"CreatedById",
"CreatedDate",
"Id",
"LastModifiedById",
"LastModifiedDate",
"LastReferencedDate",
"LastViewedDate",
"SystemModstamp"
]
}
- Select Save.
Do not create additional copy configurations. The Global copy configuration, which is installed by the Deal Manager managed package, must be the only copy configuration in the system.
Define two copy directives
You must have a copy directive for the object that you are attaching the copy control to. These directives, together with the Global copy configuration, control what the Copy action will do.
- Go to Setup > Custom Code > Custom Metadata Types.
- For the Copy Directive row, select Manage Records.
- For the Contract copy directive named Simple_Contract_Copy, select Edit.
- In the Copy Directive JSON field, specify JSON to control what is copied and whether you want to apply an IQA configuration to the copied result.
- Select Save.
- Repeat this process for the zpl_PriceLookup_c copy directive named Simple_PriceLookup_Copy and for the zpl_Deal_ccopy directive named Simple_Deal_Copy.
- The default pattern for copy directives is to include all fields from the object except for those specified in the Global copy configuration (from the previous step). You can add a fieldsToExclude property to explicitly declare additional fields to exclude during the copy operation.
- You must explicitly declare which childObjectsToInclude. If none is specified, only the parent source object is included.
- For each child object, you must explicity define the fieldsToExclude and can optionally specify additional childObjectsToInclude for each child object.
For more information about different JSON examples for a single and multiple IQA configurations, read JSON examples for the Contract copy directive topic.