beforeRemove( )


A hook that is called before a remove() operation.

The beforeRemove() hook runs when:

  • The remove() function is called.
  • An action is performed on a dataset that removes an item from the collection.
  • An item is deleted using the CMS.

The hook also runs when an action is performed on a dataset that removes an item from the collection that the dataset is connected to.

Return a string or a Promise that resolves to a string from the beforeRemove() function. The returned string will be used as the itemId parameter for the remove() operation. The item with the new itemId will be removed instead of the item with the original itemId.

If the returned value is of the wrong type, the value is ignored.

A rejected Promise blocks the call to remove() and also calls the onFailure() hook if it has been registered.

Because the beforeRemove() hook is called before remove() is executed, it can affect the item that is removed from the collection or block the remove().

Method Declaration
Copy
Method Parameters
itemIdstringRequired

The ID of the original item to be removed.


contextUpdateHookContextRequired

Contextual information about the hook.

Returns
Return Type:Promise<string> | string
Did this help?