Feature Rich
Rapid Application Development
Helping you or your customers
Manage their Business

Client Side Commands

You can perform certain database actions using JavaScript.

A number of UDB JavaScript commands have been developed to make it easy to perform these tasks.


udb.ajax.get_obj & udb.ajax.obj_data

These are responsible for retrieving an objects data from the server.

udb.ajax.get_obj(current_object_id, 'Query', function(obj){
    if (udb.ajax.obj_data(obj, 'ID') > 0) {
       console.log(udb.ajax.obj_data(obj, 'xml_tag'));
    }
});

udb.edit.live_update

This command will cause the input field value to be sent to the database.
The first parameter should contain the ID of the input element to be updated.
The second parameter can contain true or false indicating if the trigger is to be fired as if it were manually updated, or it can contain a function to call once the update has occurred. The input object will be passed as the first parameter to the function.

    val_gds = String(new_val);
    $(cForm_ID + "0_f3_val_gds").val(val_gds);
    udb.edit.live_update(cForm_ID + "0_f3_val_gds", false);

udb.list.refresh

This command will Refresh a list
The first parameter should contain the ID of the list to refresh. You can set the ID of the list using the "div_id" parameter in the LIST command.
The second parameter should contain a value to pass to page that renders the list as the list_act_val. This value can be picked up in the code with the command {REQUEST(list_act_val)}

    udb.list.refresh('myList', '');

udb.ajax.if

This command will execute a UDB Boolean expression on the server and run the relivant function on the client depending on the outcome of the expression.

    udb.ajax.if(
       current_object_id, UDB EXPRESSION,
       function(){console.log("true");},
       function(){console.log("false");}
    );

udb.ajax.page

This command will return the contents of a page. You can use this to run code on the server and return the result.

The 1st parameter is the ID of the page you want to load

The 2nd parameter is the parameters you want to pass to the page. String or Json array.

The 3rd parameter is the id or class of the destination for the result. Leaving this blank will result in the page data only being passed to the success function.

The 4th parameter is the success function that is passed the result, e.g. function(html){alert(html);}

The 5th parameter is the error function that is passed the error text if the function fails, e.g. function(err){alert(err);}

    udb.ajax.page(1234, "param1=abc", "#testcmd");

udb.userNotifications.add

Adds a notification pop-up to the screen.

The 1st parameter is the type ID of the message. 0 = Error / Danger, 1 = Info, 2 = Success, 3 = Warning. See the NOTIFY command for a full list.

The 2nd parameter is the message.

The 3rd parameter is how long the message will display for in milliseconds. 0 is forever and -1 will use default times.

The 4th parameter is the position of the message, choose from "tl", "tc", "tr", "bl", "bc", "br". Default is "tr".

    udb.userNotifications.add(2, "Record added", 5000, "br");