Custom Options Extension – Load values from a REST API with Fetch()

One of the most requested concepts is the ability to load options for an attribute from a database or from some other abstraction layer – for example from a REST API, into a Custom Options Extension.

This can be achieved using Oracle Integration Cloud or, as in this case, simply using an interview.fetch(). This fetch demonstration uses Oracle B2C Service as an example.

The goal is to present to the user, a list of service products. Then the user must choose a product. But the products need to be loaded from Oracle B2C Service.

To achieve this we need to consider the following :

  1. The list of products will be loaded into the Custom Options Extension
  2. The fetch() will be asynchronous so we need to manage this

The key effect here is that the Custom Option Extension has two variants. The first, the most common, expects an array of objects to be passed directly back to the extension as the options response. But look carefully at the official definition from the online documentation:

    customOptions: function(control, interview) {
        return {
            options: <array or function>,
            controlType: <optional>

It says “options: <array or function>” above. So what about using a function? The advantage is that the function gives us the capability to hand off the “processing” of the list to a function, and when the function has completed, we can show the values to the user. There are other advantages such as displaying a “please wait” icon when the value is null – if you intend to update the page for example when the results have been retrieved.

So our simple example with an attribute right here:

Custom Options Extension - Setup

Turns into this at runtime:

Custom Options Extension - Result

The code is relatively simple to understand:

// Custom Options Extension Example from
// Educational Purposes Only - September 2022
	customOptions: function (control, interview) {
		if (control.getProperty("name") == "xOptionsParent") {
			console.log("Custom Options Extension found " + control.getProperty("name"));
			return {
				options: myProducts(interview,control),
				controlType: "Dropdown"
function myProducts(interview, control) 
		var headers = {
				"OSvC-CREST-Application-Context": "GetProducts",
				"Content-Type": "application/json"
			var myProducts = [];
			var opts = {
				connectionName: "YOURCONNECTIONNAME",
				relativeUri: "/serviceProducts/",
				method: "GET",
				headers: headers
			try {
				.then(function (response) {
					let promise = response.json().then(function (json) {
							for (i = 0; i < json.items.length; i++) {
								myProductInstance = new Object();
								productName = json.items[i].lookupName;
								textforOption = productName;
								myProductInstance.text = textforOption.toString();
								myProductInstance.value = textforOption.toString();
							console.log("List of products now ready " + JSON.stringify(myProducts));
							console.log(response.status + " " + myProducts.length);
			} catch (e) {
			} finally {
				return myProducts;
// End of Custom Options Extension Example

We call the myProducts() function to provide the content of the Custom Options Extension options list. Then we make a standard interview.fetch() to retrieve the data. This is using version 1.4 of the Oracle B2C Service REST API, so we have to add the context header to our call. We retrieve the products, and create an object for each product with a text and value property. Then we push the object into an array. The array is returned to the Custom Options Extension.

Of course this assumes you have set up an Interview Extension Connection on your Hub and that your Oracle B2C Service instance has been configured to allow REST API calls from wherever your interview is. The example is in the Online Store.

Author: Richard Napier

After 8 years in case management and ERP software roles, Richard Napier joined Siebel Systems in 1999 and took up the role of managing the nascent Siebel University in Southern Europe. He subsequently was Director of Business Development and Education for InFact Group (now part of Business & Decisions) for 8 years. He now runs Intelligent Advisor IT Consulting OÜ. Owner of, he also is Co-Founder of the Siebel Hub.

One thought on “Custom Options Extension – Load values from a REST API with Fetch()

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Intelligent Advisor IT Consulting Serving Customers Worldwide
Hide picture