Parameters for a Schedule-based Hook

This topic explains function parameters when an endpoint in server code is called by a schedule-based hook.

An endpoint is defined in the following way as shown in Server Code Syntax.

// Synchronous function
function funcName(params, context) {
  // Your code comes here...
}

// Asynchronous function
function funcName(params, context, done) {
  // Your code comes here...
}
  • The function name funcName becomes an endpoint name. You will use this endpoint name to associate a server hook (schedule) with the target function when you register the server code with the command line tool.
  • The first argument params is used to get parameters specified in the server hook configuration file. If you set "arg1" : "xxxx" in Schedule-based Hook, for example, you can get the value xxxx with the params.arg1.
  • The second argument context is used to get the application-related parameters.
    • Use the getAppID method to get the AppID.
    • Use the getAppKey method to get the AppKey.
    • The getAccessToken method will always return null.
    • Use getAppAdminContext method to get the app admin context (KiiAppAdminContext). You can execute user and group operations as an app admin with this context (See the sample code in Administrator).
  • The third argument done is a callback function for finishing the asynchronous server code. The value passed to this callback function will be recorded in the developer log. See Asynchronous execution for more details.

When server code is executed with a schedule-based hook, all return values from the server code are recorded in the developer log. You can browse the log with the command line tool. In the log, values specified in the return statement (for synchronous code) and the values passed to the done function (for asynchronous code) are recorded.