Callback function in Aware IM?
Re: Callback function in Aware IM?
I did as suggested. I already had a similar 'dummy' process which I had called 'Void' - I needed this in some other areas. That process has just one rule, but that rule is disabled. The process has no
I then created another row operation "Start process" which calls this 'Void' process. And believe it or not, the same situation happened as before: the BO rules were being executed promptly upon clicking the "Dummy" row operation (and in fact simultanous with the execution of the dummy process itself).
I should perhaps add that this row has inline editing, and that I select the row operation after having made some edits in the line. So the 'dirty' flag for the line is set (as marked by the small black triangle in the left upper corner of the cell). Most likely, in this situation the changes to the line item are being saved (causing the BO rules to execute) automatically when a row operation is selected.
I then created another row operation "Start process" which calls this 'Void' process. And believe it or not, the same situation happened as before: the BO rules were being executed promptly upon clicking the "Dummy" row operation (and in fact simultanous with the execution of the dummy process itself).
I should perhaps add that this row has inline editing, and that I select the row operation after having made some edits in the line. So the 'dirty' flag for the line is set (as marked by the small black triangle in the left upper corner of the cell). Most likely, in this situation the changes to the line item are being saved (causing the BO rules to execute) automatically when a row operation is selected.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)
Re: Callback function in Aware IM?
I had a look in the queryLayoutParser.js file, which confirmed what I had suspected. See code below copied from that file (lines 5044-5069 in v9.0 build 3272):
This function runItemOperation is called whenever a Row Operation is initiated. The relevant portion here is the line
And here is the function saveInlineEditChanges and related function saveInlineEdits (lines 4069 - 4102 in v9.0 build 3272):
The line "grid.dataSource.sync ();" saves the changes in the grid to the server, which causes the BO to update.
As mentioned before, in itself there is no problem that the BO is recalculated. It's just unfortunate that this update is apparently simultanous with the process being executed, instead of first finalizing the changes to the BO (including evaluation of all BO rules), and only then executing the process.
Code: Select all
runItemOperation: function (link)
{
var link = $(link);
// operation is in a special attribute of the link
var operIdx = link.attr ("data-operidx");
if (! this.m_itemOpers || this.m_itemOpers.length <= operIdx)
return;
if (this.m_editingMode == "incell")
this.saveInlineEditChanges();
var oper = this.m_itemOpers[operIdx];
var row = link.closest("tr");
this.doRunItemOperation (this.getWidget(), oper, row);
},
(Note that what in Aware describes as "inline editing" is in fact what Kendo calls "incell editing").if (this.m_editingMode == "incell")
this.saveInlineEditChanges();
And here is the function saveInlineEditChanges and related function saveInlineEdits (lines 4069 - 4102 in v9.0 build 3272):
Code: Select all
saveInlineEditChanges: function ()
{
this.saveInlineEdits ("save");
},
saveInlineEdits: function (mode, ctx)
{
var grid = this.getWidget();
if (! grid)
return false;
if (this.m_pendingSave || ! grid.dataSource.online ())
return false; // saving already
if (grid.dataSource.hasChanges ())
{
this.m_pendingSave = { rowIdx: this.m_curEditedRowIdx, mode: mode, ctx: ctx };
this.m_recalcAttrName = null;
// failure is handled by data source error
grid.dataSource.sync ();
return true;
}
else if (this.m_wasRecalculating)
{
this.sendEvents(grid);
}
this.m_wasRecalculating = false;
return false;
},
As mentioned before, in itself there is no problem that the BO is recalculated. It's just unfortunate that this update is apparently simultanous with the process being executed, instead of first finalizing the changes to the BO (including evaluation of all BO rules), and only then executing the process.
Last edited by nhofkes on Thu Aug 22, 2024 5:32 pm, edited 2 times in total.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)
-
- Posts: 7572
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Callback function in Aware IM?
Jaymer is right - you need to provide a little bit more clarity.
From your log it seems that the Update operation is executed as a request from the user interface AND that the process invoked from a row operation is executed AFTER the update. This means that something is happening before the process starts - this is where you need to focus. There is the Transaction_Edit process that is suspended just before the object is updated. What does this process do and why is it suspended?
I know for a fact that the rules of the object are NOT executed automatically when a row operation is invoked. And for a particular user everything happens synchronously unless they somehow manage to click several buttons in quick succession.
See if you can reproduce this in a small application - I doubt that you will.
From your log it seems that the Update operation is executed as a request from the user interface AND that the process invoked from a row operation is executed AFTER the update. This means that something is happening before the process starts - this is where you need to focus. There is the Transaction_Edit process that is suspended just before the object is updated. What does this process do and why is it suspended?
I know for a fact that the rules of the object are NOT executed automatically when a row operation is invoked. And for a particular user everything happens synchronously unless they somehow manage to click several buttons in quick succession.
See if you can reproduce this in a small application - I doubt that you will.
Aware IM Support Team
Re: Callback function in Aware IM?
Strictly speaking, yes. Invoking the row operation does not in itself result in execution of the object rules. However, the situation is different when the row operation is on a grid with inline editing enabled AND such edits having been made in the row when the row operation is invoked. In that case, when the row operation is invoked, the changes in the grid row (incell edits) are saved (synced with the datasource), resulting in a change in the object that is displayed in that particular row and therefore trigger the object rules to execute.aware_support wrote: ↑Mon Aug 12, 2024 11:23 pm I know for a fact that the rules of the object are NOT executed automatically when a row operation is invoked.
Thus, invoking the row operation results in saving the changes in the grid which triggers the execution of the object rules.
According to the log, in this specific situation the object rules are executed at the same time (in parallel) as the execution of the process that is called from the row operation. Also if just one button is clicked. I believe this is caused by the fact that the call to grid.dataSource.sync() is an asynchronous operation.aware_support wrote: ↑Mon Aug 12, 2024 11:23 pm And for a particular user everything happens synchronously unless they somehow manage to click several buttons in quick succession.
Yes, I will put that together.aware_support wrote: ↑Mon Aug 12, 2024 11:23 pm See if you can reproduce this in a small application - I doubt that you will.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)
-
- Posts: 7572
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Callback function in Aware IM?
I see - inline editing was the detail that I missed. With inline editing on, what you are saying is most probably true. I will investigate tomorrow what you can do about it.
If you prepare a small BSV that would save me some time.
If you prepare a small BSV that would save me some time.
Aware IM Support Team
-
- Posts: 7572
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Callback function in Aware IM?
I had a look at the code. It can be done with some custom Javascript:
1) You need to change the type of the operation from StartvProcess to Execute Javascript.
2) Then you have to add the following scrript:
var grid = parser.getWidget ();
int count = 0;
var id = setInterval (function () {
if (! grid.dataSource.hasChanges () || ++ count > 100)
{
clearInterval (id);
parser.startProcess ("YourProcessName", context[0].objectName, context[0].objectId, null, null, true);
// The last null is the target of the operation; null corresponds to Default, but can be "popup" or "new_tab" or a few other settings
// last value of true is for noAutoRefresh flag
}
}, 200);
1) You need to change the type of the operation from StartvProcess to Execute Javascript.
2) Then you have to add the following scrript:
var grid = parser.getWidget ();
int count = 0;
var id = setInterval (function () {
if (! grid.dataSource.hasChanges () || ++ count > 100)
{
clearInterval (id);
parser.startProcess ("YourProcessName", context[0].objectName, context[0].objectId, null, null, true);
// The last null is the target of the operation; null corresponds to Default, but can be "popup" or "new_tab" or a few other settings
// last value of true is for noAutoRefresh flag
}
}, 200);
Aware IM Support Team
Re: Callback function in Aware IM?
Thanks.
It seems that the line "int count = 0;" should be "let count = 0;" or "var count = 0;" as 'int' is not a valid keyword in Javascript.
Meanwhile, I have been working on a slightly different approach: catching the mouseclick event in the render script of the grid, syncing the grid and then invoking the row operation as normal. This is because I already have a render script for other reasons, and in this way I can keep all the Javascript together and I don't have to change the row operation itself. I have that almost working now. Will report back here when it does.
It seems that the line "int count = 0;" should be "let count = 0;" or "var count = 0;" as 'int' is not a valid keyword in Javascript.
Meanwhile, I have been working on a slightly different approach: catching the mouseclick event in the render script of the grid, syncing the grid and then invoking the row operation as normal. This is because I already have a render script for other reasons, and in this way I can keep all the Javascript together and I don't have to change the row operation itself. I have that almost working now. Will report back here when it does.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)
-
- Posts: 7572
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Callback function in Aware IM?
"It seems that the line "int count = 0;" should be "let count = 0;" or "var count = 0;" as 'int' is not a valid keyword in Javascript."
Yes, most definitely
Yes, most definitely
Aware IM Support Team
Re: Callback function in Aware IM?
It took me a bit longer than expected, but this render script can now be found in this post in the Tips & Tricks section, with a short explanation.nhofkes wrote: ↑Wed Aug 14, 2024 6:46 am Meanwhile, I have been working on a slightly different approach: catching the mouseclick event in the render script of the grid, syncing the grid and then invoking the row operation as normal. This is because I already have a render script for other reasons, and in this way I can keep all the Javascript together and I don't have to change the row operation itself. I have that almost working now. Will report back here when it does.
In comparison to the custom javascript code for the row operation suggested above, the advantage of the render script is that it is a more generic approach: it works for all row operations on the grid and does not require any custom javascript in the row operations themselves.
This is of course a work-around. It would be better if the issue is resolved by an update in the grid parser. See the request for this in this post.
Niels
(V9.0 build 3272 - MariaDB - Windows)
(V9.0 build 3272 - MariaDB - Windows)
-
- Posts: 7572
- Joined: Sun Apr 24, 2005 12:36 am
- Contact: