Customize Fetch Action Chain in VBCS

Customize Fetch Action Chain in VBCS

In Oracle Visual Builder Cloud Service (VBCS), a Customize Fetch Action for an SDP (Service Data Provider) is a way to override the default data fetching behavior and write custom logic (typically JavaScript) to control how and what data the SDP retrieves from a service or other sources.

In this post, we will see how to implement custom fetch action chain for SDP in VBCS.

Let us consider below Select (Single) components. The SDP variable is assigned to Single Select components. The SDP is based on Fusion REST API endpoint for AP Invoice.

Search Invoice Number by partial type as “test”

A screenshot of a computer

AI-generated content may be incorrect.

This will show all invoice numbers starting with “test”.

Let us search with “test CM”.

A screenshot of a computer

AI-generated content may be incorrect.

This will also provide you with the result.

Let us search now with “test cm”.

A close-up of a match

AI-generated content may be incorrect.

No result was found.

Hence the Search is case sensitive.

If we want to make search case-insensitive, we can do it using custom fetch action chain for SDP.

Follow the steps below to achieve this.

Select (Single) component is associated with SDP variable as shown:

A screenshot of a computer

AI-generated content may be incorrect.

Navigate to this SDP variable.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Customize Fetch Action chain.

This will open a new action chain.

A screenshot of a computer

AI-generated content may be incorrect.

This action chain will consist of one REST API call and return component.

Also action chain is having parameter as “configuration”.

This configuration parameter captures value which we type in Select Single field.

We can capture value which is typed in select Single combo box using “configuration.hookHandler.context.fetchOptions.filterCriterion.text”.

Let us capture the value and add Fire Notification to display the value.

Navigate to code of action chain.

A screenshot of a computer

AI-generated content may be incorrect.

Add below code:

  1. let searchText = “”;
  2. if (configuration &&
  3. configuration.hookHandler &&
  4. configuration.hookHandler.context &&
  5. configuration.hookHandler.context.fetchOptions &&
  6. configuration.hookHandler.context.fetchOptions.filterCriterion &&
  7. configuration.hookHandler.context.fetchOptions.filterCriterion.text) {
  8. searchText = configuration.hookHandler.context.fetchOptions.filterCriterion.text;
  9. searchText=searchText.toUpperCase();
  10. }
A screenshot of a computer program

AI-generated content may be incorrect.

Now add fire notification and assign searchText local variable.

A screenshot of a computer

AI-generated content may be incorrect.

Run the application.

A screenshot of a computer

AI-generated content may be incorrect.

Now we will build query parameter to remove case sensitivity and will pass to REST API call.

A screenshot of a computer

AI-generated content may be incorrect.

Click on query parameter.

A screen shot of a computer

AI-generated content may be incorrect.

Add below expression for query parameter:

  1. upper(InvoiceNumber) LIKE ‘” + searchText + “%'”

Click on save.

Add return to return response.

A screenshot of a computer

AI-generated content may be incorrect.

Add else condition to display all records if user is not selecting any value.

We don’t need to pass query parameter for else condition.

A screenshot of a chat

AI-generated content may be incorrect.

Run the application.

A screenshot of a computer

AI-generated content may be incorrect.

Search with test cm.

A screenshot of a computer

AI-generated content may be incorrect.

Using customize fetch action chain for SDP, we have removed case sensitivity for search text.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top