Requesting a Webroutine

LANSA WAM

Requesting a Webroutine

The Lstd.Json.getWebroutine(options) method provides a way for your JavaScript code to call a Webroutine. Any webrouting can be called with this method but only a JSON Response Webroutine can return data to it. The single options parameter is a JavaScript object containing zero or more of the following properties:

Wam

The WAM being called. If not present, the current WAM is used.

webroutine

The Webroutine being called. If not present, the current webroutine is used.

Fields

A JavaScript object containing the input values to send to the Webroutine. For example:

{

GIVENAME: "William",

SURNAME: "Shakespeare"

}

Lists

A JavaScript object containing lists to send to the Webroutine. Each list is an array or rows and each row is an object containing column values. For example:

{

LIST01: [

{DEPTMENT: "ADM", DEPTDESC: "Administration"},

{DEPTMENT: "FIN", DEPTDESC: "Finance"}

]

}

callback

A JavaScript function that will be called when the Ajax request is completed. This function is only called on successful completion of a call to a JSON Response Webroutine. It will be passed a single parameter containing a Webroutine object that represents the Webroutine output.

 

 

Putting it all together, you get something like this:

 

/*

* Get webroutine (Ajax request)

* Webroutine (wr) is passed to the callback wrapped in an Lstd.Json.Wr object

*/

var options = {

wam: "SampleWam",

webroutine: "Sample1",

fields: {

GIVENAME: "John",

SURNAME: "Smith"

},

lists: {

LIST01: [

{DEPTMENT: "ADM", DEPTDESC: "Administration"},

{DEPTMENT: "FIN", DEPTDESC: "Finance"}

]

},

callback: function(wr) {

// Code to handle the Ajax response goes here

}

};

 

Lstd.Json.getWebroutine(options);

 

The Webroutine object passed to the callback function contains a number of methods for getting the fields and lists returned from the server.