X

The Visual Builder Cloud Service Blog

  • May 17, 2018

Custom JS Functions in VBCS Apps

John Jullion-Ceccarelli
Product Manager

When writing custom Javascript functions in your VBCS apps, you have to declare your functions in a certain way. That's because Oracle JET and VBCS use Require.js to handle modularity. 

So if defining a new Page function, use the following format:

PageModule.prototype.getLOVMeaningValue = function(args) {};

For example:

define([], function () {

    'use strict';

    var PageModule = function PageModule() {};

    PageModule.prototype.getLOVMeaningValue = function (key, lovs) {

        var res;
        var keyProperty = Object.keys(lovs[0])[0];
        lovs.forEach(function(record) {
                if (record[keyProperty] === key) {
                    res = record;
                }
            });

        if (res) {
            return res[Object.keys(res)[1]];
        }
    };

    return PageModule;

});

For Flow level functions, use FlowModule.prototype, and for App level functions, use AppModule.prototype

Join the discussion

Comments ( 1 )
  • Rodrigo Garcia Wednesday, February 27, 2019
    Do I need to instance the Javascript Functions on my code component and If I do, how do I do that?
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.