---
schema_version: "1"
id: bb4ae49c63516f09340499dbb263eef65800e40013a2c91a0a882fd4feb56524
title: Create Hooks for MultiServiceAppHandler
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_t_create_hooks_for_multiserviceapphandler_214290.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_t_create_hooks_for_multiserviceapphandler_214290.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 93ac22bac5e0ceaae2886d84d2880978cc4bca6d13288b5d46ac4b8be82628fb
description: The Multisite APIs provide an option to write custom pre- and post-hooks for each API to implement custom logic. A pre-hook is run before the actual API runs. A post-hook runs after the actual API runs.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# Create Hooks for MultiServiceAppHandler

The Multisite APIs provide an option to write custom pre- and post-hooks for each API to implement custom logic. A pre-hook is run before the actual API runs. A post-hook runs after the actual API runs.

1. Write the custom class to implement the pre and post hook.
    
    Example code:
    
    ```
    1 global with sharing class MSCustomHookImplementation implements vlocity_cmt.VlocityOpenInterface
    2 {
    3  global Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) 
    4  {
    5    if( methodName.equalsIgnoreCase('getGroups.PreInvoke')) 
    6    {
    7      getGroups_PreInvoke(methodName, input, output,options);
    8      return true;
    9    }
    10    
    11    if( methodName.equalsIgnoreCase('getGroups.PostInvoke'))
    12    {
    13      getGroups_PostInvoke(methodName, input, output,options);
    14      return true;
    15    }
    16    
    17    return false;
    18  }
    19  
    20  private void getGroups_PreInvoke(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) 
    21  {
    22    //This method gets called before getGroups
    23  }
    24  private void getGroups_PostInvoke(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) 
    25  {
    26    //This method gets called after getGroups
    27  }
    ```
2. Create the interface implementation.
    
    - From the App Launcher, click **Interface Implementations**.
    - Click **New**.
    - In the New Interface Implementation dialog, enter the following:
        
        - **Interface Name:** MSAppHandlerHookInterface
        - **Active Implementation Class:** MSCustomHookImplementation (Name of Custom Class)
    - Click **Save**.
3. Create a new Interface Implementation Detail for the interface created above.
    
    - On the Related tab for your new custom interface implementation, click **New**.
    - In the New Interface Implementation Detail dialog, enter MSCustomHookImplementation for **Available Implementation**.
    - Click **Active** to make this implementation the active implementation.
    - Click **Save**.