Removing a button from a Layout
This article will be walking through the Swantide example workflow: [Swantide Example] Layout Button Removal Functionality if you don't see this workflow in your workflow manager, reach out to your support team to get access.
Metadata Component
Metadata Lines:
We are isolating this workflow to only update the list of buttons on the layout. To do that, we only bring in the lines of metadata that reference buttons (platformActionList) so that no other elements of the workflow are changed.
Example: if instead you were trying to remove and add fields to the layout, you would have only those layout lines brought in and platform action list lines would be removed.
The metadata component has the following variable aliases:
"Account-Account Layout" represents the variable alias for the Page Layout Name that should be updated. The way this specific workflow is set up that this is a variable that allows the user to select a page layout to update buttons on
UPDATEDBUTTONLISTVAR: this is the variable alias that will create the new list of buttons, using the existing list and removing the button defined in the variable
NEW_BUTTONVAR: this is the variable alias for the new button that you'd like to add to the updated list. If you wanted to not add a new button you could delete this alias from the metadata and the associated variable
{
"fullName": "Account-Account Layout",
"platformActionList": {
"actionListContext": "Record",
"platformActionListItems": [
"UPDATEDBUTTONLISTVAR",
"NEW_BUTTONVAR"
]
}
}
Other Elements:
The Deploy rule is patch since we are updating an existing layout
Type is layout based on updating a layout
The API name is also the "Account-Account Layout" variable alias, to define which layout should be updated
Variables
Variable to leverage the appropriate layout's metadata definition. This allows two pieces of functionality: a) the user can pick the layout they want to update with the Account-Account Layout variable alias and b) unlocks the metadata definition of the layout that is chosen so that we can access the existing list of buttons
Tip: this could be a hidden variable if you do not want the user to select the page layout to update and instead have it be hard coded. In this case, the Account-Account Layout Usage alias could be deleted.
Create Updated list using the metadata definition that removes the appropriate button(s) this is a hidden variable to hard code the buttons that you'd like to remove from the list using a variable formatter.
The default value of LAYOUTMETADATAVAR[[platformActionList]][[platformActionListItems]] takes the list of buttons (from variable 1b above), finds the buttons that should be removed (defined in the usage value, ex Account.Oldbuttonname) and recreates the list without those buttons to add to the metadata component.
Tip: Using the double brackets "[[X]]" accesses any item in a metadata definition of a variable. In this case, the Layout chosen has a variable alias defined as LAYOUTMETADATAVAR and the usage accesses the metadata definition so that we can pull in the platformActionList and other sub-lines to bull in the existing lists from the chosen layout.
Variable to add in the hardcoded button to the selected page layout this is a simple and optional variable to add in a new button to the updated list. It hardcodes a new button (in this example the api name is Account.AddNew_Button_toList) and adds it to the NEW_BUTTONVAR metadata component alias in the metadata component







