Hi,
I'm am using KUIB 1.1 and trying it's blank view.
This is the view I created following the tutorial provided.
I have added button with name "Invoke". I want to call an invoke type operation when i click on the invoke button. I have assigned onClick event with function name "onInvokeCall". And also defined onInvokeCall in view-factory.js file.
I have also defined a invoke type method GetCreditInfo() in the CustomerBE.cls. I want to call this function when i click in the invoke button.
I have followed this tutorial.
https://documentation.progress.com/output/pdo/index.html#page/pdo%2Fclient-javascript-code-3a-an-invoke.html%23
But, I'm confused how to invoke function and how do i subscribe to the afterInvoke events in KUIB. I have attached the files I'm working on.
Regards,
Bidhan
[View:/cfs-file/__key/communityserver-discussions-components-files/255/customer_2D00_list.rar:320:240]
Hello Bidhan,
The key to calling invoke operations is to access the JSDO instance associated with the datasource.
Your reference to the JSDO would look like "this.scope._$ds.CustomerDS.transport.jsdo" or "this.customerDS.transport.jsdo" if you have saved the reference in the view factory.
Please notice that the sample code saves a reference to the model. This works fine if you are working with a form, however, if you are using a grid or a grid + form, the model instance may change and the saved reference would not point to the current model.
Once that you have the JSDO instance, you would use the invoke() method:
this.scope._$ds.CustomerDS.transport.jsdo.invoke("GetCreditInfo", {});
You can handle the response from the invoke operation either via a subscribe or a promise. (You can also use both, i.e., use a promise and also subscribe to the AffterInvoke event.)
If you prefer to use a subscribe, you can specify it in the onShow in the view-factory.js using the following code:
this.scope._$ds.CustomerDS.transport.jsdo.subscribe("AfterInvoke", "GetCreditInfo", this.onAfterInvoke);
If you prefer to use a promise, you would call the invoke operation and specify a function for done and for fail:
var promise = this.scope._$ds.CustomerDS.transport.jsdo.invoke("GetCreditInfo", {});
promise.done(function (jsdo, success, request) {
console.log("Success: " + JSON.stringify(request.response));
});
promise.fail(function (jsdo, success, request) {
console.log("Error: ");
});
Please let me know if you need more info.
Cheers,
Edsel
Hello Bidhan,
The key to calling invoke operations is to access the JSDO instance associated with the datasource.
Your reference to the JSDO would look like "this.scope._$ds.CustomerDS.transport.jsdo" or "this.customerDS.transport.jsdo" if you have saved the reference in the view factory.
Please notice that the sample code saves a reference to the model. This works fine if you are working with a form, however, if you are using a grid or a grid + form, the model instance may change and the saved reference would not point to the current model.
Once that you have the JSDO instance, you would use the invoke() method:
this.scope._$ds.CustomerDS.transport.jsdo.invoke("GetCreditInfo", {});
You can handle the response from the invoke operation either via a subscribe or a promise. (You can also use both, i.e., use a promise and also subscribe to the AffterInvoke event.)
If you prefer to use a subscribe, you can specify it in the onShow in the view-factory.js using the following code:
this.scope._$ds.CustomerDS.transport.jsdo.subscribe("AfterInvoke", "GetCreditInfo", this.onAfterInvoke);
If you prefer to use a promise, you would call the invoke operation and specify a function for done and for fail:
var promise = this.scope._$ds.CustomerDS.transport.jsdo.invoke("GetCreditInfo", {});
promise.done(function (jsdo, success, request) {
console.log("Success: " + JSON.stringify(request.response));
});
promise.fail(function (jsdo, success, request) {
console.log("Error: ");
});
Please let me know if you need more info.
Cheers,
Edsel
Hi egarcia,
Thanks for the response. It works.