getFromExternal()
The getFromExternal() function (client-side) lets a script asynchronously communicate with its parent window to send a data request or perform a task. The parent window may be a SuiteCommerce web store, an external web application, or any environment that embeds the product interface in an iframe.
Syntax
Use this syntax for the getFromExternal() function:
getFromExternal('taskName', request)
.done(callback)
.fail(callback);
Return Value
The getFromExternal() function returns a promise that resolves to a jQuery deferred object containing the data provided by the parent window response.
Parameters
The task name is required.
The getFromExternal() function accepts the following parameters:
-
taskName- Specifies the name of the task that you want the parent window to perform in string format. This parameter serves as an identifier for the type of request. -
request- Specifies an object, string, or number representing any additional data to send to the parent window.
Examples
The following examples show how to use the getFromExternal() function.
Retrieving the Order ID from the Parent Window
This example calls a parent window function named getOrderId to retrieve the current order ID. The script sends the task request, and then handles both success and error outcomes using callbacks.
getFromExternal('getOrderId')
.done(function (orderId) {
console.log('Host returned orderId =', orderId);
})
.fail(function (err) {
console.error('Failed to get order ID:', err);
});