Message Formats

You can send a message to a plugin as a string, containing serialized JSON data, or as a raw JavaScript object.

Here’s an example of a message that's sent as a string containing serialized JSON data:
window.parent.postMessage('{"apiVersion":1,"method":"close","activity":{"cname":"John"}}', targetOrigin);
Here’s an example of a message that's sent as a raw JavaScript object:
window.parent.postMessage({
    apiVersion: 1,
    method: 'close',
    activity: {
        cname: 'John'
    }
}, targetOrigin);
You can update file properties only by using a JavaScript object as message data. See File properties for details. Similarly, the plugin must process the messages that it receives. Oracle Fusion Field Service always sends the data to the plugin as a serialized JSON string and never as a raw object. For example:
function getPostMessageData(event)
{
    var data = JSON.parse(event.data);
    switch (data.method)
    {
        case 'open':
            pluginOpen(data);
        break;
        default:
            showError();
    }
};
  
window.addEventListener("message", _getPostMessageData, false);
JSON data is an object (hash) of a defined format, and contains common fields (that describe the message itself) and fields that are specific for different 'methods' (for example, that hold Oracle Fusion Field Service entities data), for example:
{
    "apiVersion": 1,
    "method": "open",
    "entity": "activity",
    "resource": {
        "pid": 5000038
    },
    "inventoryList": {
        "20997919": {
            "invid": 20997919,
            "inv_pid": 5000038,
        }
    }
} 
Where:
  • apiVersion, method: Common fields.

  • entity: Name of the Oracle Fusion Field Service entity that's to be processed by the plugin. Available only for the 'open' method.

  • resource, inventoryList: Entity data collections. Available only for 'open' and 'close' methods.

Common Fields
  • apiVersion: Version of the plugin API that's used for interaction between and Oracle Fusion Field Service and the plugin. Available methods and data depend on it. This is a required parameter. You must include this parameter in the message for the plugin to be processed without any errors.

  • method: Describes the action initiated by Oracle Fusion Field Service or the plugin, and the actions that should be performed by other side.