wakeup Message

Oracle Fusion Field Service destroys a plugin's iframe window after the close message is successfully run, regardless of whether the device is online or offline. So, no JavaScript code runs after the plugin is closed. However, the plugin may have data, which must be synchronized with its server side, Oracle Fusion Field Service REST API, or third-party services. Hence, the wakeup parameter is available with the close message.

wakeupNeeded with close

The optional parameter wakeupNeeded is added to the close message to let the plugin synchronize its data as mentioned earlier. If wakeupNeeded is set to true, the Oracle Fusion Field Service Core Application opens the plugin's hidden iframe in the background, as soon as Oracle Fusion Field Service Core Application is online, but no earlier than 10 seconds after the plugin is closed. After the plugin iframe is opened, Oracle Fusion Field Service Core Application sends the wakeup message to the plugin, in response to the ready message. The plugin then sends the sleep message back to Oracle Fusion Field Service Core Application, when it finishes synchronization. This lets Oracle Fusion Field Service Core Application destroy the iframe.

If the plugin tries to synchronize, but still has data to be sent, it sends the sleep message with the wakeupNeeded param set to true. In this case, Oracle Fusion Field Service Core Application opens the plugin's iframe in the background again, as soon as Oracle Fusion Field Service Core Application is online, but no earlier than five minutes after the plugin is closed. If the plugin doesn't send the sleep message in two minutes (120 s) after the wakeup message is sent, Oracle Fusion Field Service Core Application destroys its iframe and reopens it again, as if the plugin sent the sleep message with the wakeupNeeded param set to true.

Example of close with wakeupNeeded
{
    "apiVersion": 1,
    "method": "close",
    "activity": {
        cname: "John"
    },
    "wakeupNeeded": true,
    "wakeOnEvents": {
        "online": { wakeupDelay: 120 },
        "timer": { wakeupDelay: 10, sleepTimeout: 1800 }
    }
}

wakeupNeeded with initEnd

The optional parameter wakeupNeeded is added to the initEnd message, to let the plugin synchronize even after refreshing Oracle Fusion Field Service Core Application or closing the browser. If the plugin doesn't synchronize within two minutes that is allowed for initialization, it sends the initEnd message with the wakeupNeeded parameter set to true. In this case, Oracle Fusion Field Service Core Application opens the plugin's iframe in the background, as soon as Oracle Fusion Field Service Core Application is online, but no earlier than five minutes after it receives the initEnd message.

The plugin opens in five minutes after it's closed, if the wakeupNeeded parameter of close, sleep, or initEnd messages is set to true. This happens even if Oracle Fusion Field Service Core Application doesn't detect the offline mode, when the plugin is opened or closed. If the user opens the plugin by clicking its button, the background iframe is destroyed without sending any messages to the plugin. If the plugin still has data to be synchronized, it sends the close message with the wakeupNeeded parameter set to true.

Example of wakeup Message for the online event
{
    "apiVersion": 1,
    "method": "wakeup",
    "event": online
}
Example of wakeup Message for the timer event
{
    "apiVersion": 1,
    "method": "wakeup",
    "event": timer
}

Configure the Frequency and Duration of a Background Operation

Apart from the wakeupNeeded field, you can also use the optional field wakeOnEvents to control the frequency and duration of a plugin's background operation. This field is applicable only for close, initEnd, and sleep methods. If the wakeupNeeded field is absent, empty, or is set to false, then the wakeOnEvents field is ignored.

The value of wakeOnEvents is an object with two possible keys, which define the event for which the plugin must be opened for background operation:
  • online: If this field is set and is not null, the plugin is opened in the background only when Oracle Fusion Field Service is online, as if wakeOnEvents field was not sent.
  • timer: If this field is set and is not null, the plugin is opened in the background regardless of the connection status.
The value of these fields has the same format - it's an object with two optional fields:
Field Type Min Value Max Value Default Value Description
wakeupDelay Number (integer) 10 - 300

Delay (in seconds), after which Oracle Fusion Field Service opens the plugin in the background and sends a wakeup message.

Oracle Fusion Field Service wakes a plugin as close as possible to the requested time, but not earlier than that. The actual time may be longer because of the browser's limitations.

sleepTimeout

Number

(integer)

10 3600 120 Duration in seconds, after which Oracle Fusion Field Service forcibly closes a background frame of the plugin if it hasn't sent a sleep message explicitly. This period starts when Oracle Fusion Field Service sends the wakeup message to the plugin.

If both online and timer are set, the plugin is opened on the first event for which all conditions are met (wakeupDelay period has passed, Oracle Fusion Field Service is online (for the online event)).

If both fields have the same value for wakeupDelay and Oracle Fusion Field Service is online, then there's no guaranteed order of wakeup events.

The default value for wakeOnEvents is { online: {} }. That is, the plugin is woken only on an online event with a default delay to maintain backward compatibility.

If wakeOnEvents is set and is empty, or all its fields equal to null, it's equivalent to wakeupNeeded: false.

Background synchronization schedule is discarded as soon as the plugin sends the close, initEnd, or sleep message. So if a plugin has to be opened in the background again after that, it must send the new (or the same) value of wakeupNeeded and wakeOnEvents in the close, initEnd, or sleep message.

Note: Constant working of plugins in the background is not advised, as it may negatively affect a device's performance (hence the user experience) and its battery life. However, if it is necessary for your business, then the best practice is to set a higher value for sleepTimeout (up to 3600 s (1 hour)). This helps to avoid repeated reopening and closing of the plugin's frame in high-frequency series (which will be the case if the values of wakeupDelay and sleepTimeout both set to low values and waking up is requested by each sleep message).
Available Message Fields for wakeup:
  • eventName: Name of the wakeup event which caused the error (if applicable).
  • paramName: Name of the event field which caused error (if applicable).