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:

    11 global with sharing class MSCustomHookImplementation implements vlocity_cmt.VlocityOpenInterface
    22 {
    33  global Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)
    44  {
    55    if( methodName.equalsIgnoreCase('getGroups.PreInvoke'))
    66    {
    77      getGroups_PreInvoke(methodName, input, output,options);
    88      return true;
    99    }
    1010
    1111    if( methodName.equalsIgnoreCase('getGroups.PostInvoke'))
    1212    {
    1313      getGroups_PostInvoke(methodName, input, output,options);
    1414      return true;
    1515    }
    1616
    1717    return false;
    1818  }
    1919
    2020  private void getGroups_PreInvoke(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)
    2121  {
    2222    //This method gets called before getGroups
    2323  }
    2424  private void getGroups_PostInvoke(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)
    2525  {
    2626    //This method gets called after getGroups
    2727  }
  2. Create the interface implementation.

    1. From the App Launcher, click Interface Implementations.

    2. Click New.

    3. In the New Interface Implementation dialog, enter the following:

      • Interface Name: MSAppHandlerHookInterface

      • Active Implementation Class: MSCustomHookImplementation (Name of Custom Class)

    4. Click Save.

  3. Create a new Interface Implementation Detail for the interface created above.

    1. On the Related tab for your new custom interface implementation, click New.

    2. In the New Interface Implementation Detail dialog, enter MSCustomHookImplementation for Available Implementation.

    3. Click Active to make this implementation the active implementation.

    4. Click Save.