I have an expense app where I decoupled the image from the list SQL data source. This makes the app lighter and more efficient with heavy user load. The image is displayed on demand via an Ajax callback. If a user returns a filtered list with 40 records, chances are they are not going to look at all 40 images. Users just want to know when they get paid. Everything works great except with a poor cellular connection. The app requires a connection. This is by design. To simplify, I am only showing the code that relates to this issue.
When the following code is executed, how do I wait until the primary key is known. It would be nice to have an option like AJAX action java script where a java script function can be executed AFTER the server update is complete. No such option exist for the saveListEdits method.
var lObj = {dialog.object}.getControl('List_Expenses');
lObj.updateListFromUXControls();
{dialog.object}.saveListEdits('List_Expenses',{rows: 'current'});
setTimeout(function(){ saveimage(); }, 4000);
I don't try to save the image until 4 seconds have elapsed. 4 seconds is an arbitrary number. I would prefer to execute as soon as the primary key is known to avoid unnecessary delay when connection is good.
In the saveimage() function below, I added this code to check if the ExpenseID exist to make sure my Ajax callback will save the image properly to the new record.
When connection is decent, everything works as expected (99% of time)
function saveimage() {
var nExpenseID = {dialog.object}.getValue('ExpenseID');
if(nExpenseID == '' || nExpenseID == null)
{
alert("The app has detected that your image may not be saved. Go back to expense list and tap details to insure your image has been saved. Retake picture if needed.");
alert("This problem is due to bad connection. You need 2 or more bars");
}
var imageCtrl = {dialog.Object}.getPointer('RECEIPTIMAGE');
var photoData = imageCtrl.src;
var photoDataEnc = encodeURIComponent(imageCtrl.src);
{dialog.object}.ajaxCallback('','','xbUpdateImage','','__photoData=' + photoDataEnc,{onComplete: function() }
}
I know there are many ways to accomplish things in Alpha. Any help or suggestions would be greatly appreciated.
When the following code is executed, how do I wait until the primary key is known. It would be nice to have an option like AJAX action java script where a java script function can be executed AFTER the server update is complete. No such option exist for the saveListEdits method.
var lObj = {dialog.object}.getControl('List_Expenses');
lObj.updateListFromUXControls();
{dialog.object}.saveListEdits('List_Expenses',{rows: 'current'});
setTimeout(function(){ saveimage(); }, 4000);
I don't try to save the image until 4 seconds have elapsed. 4 seconds is an arbitrary number. I would prefer to execute as soon as the primary key is known to avoid unnecessary delay when connection is good.
In the saveimage() function below, I added this code to check if the ExpenseID exist to make sure my Ajax callback will save the image properly to the new record.
When connection is decent, everything works as expected (99% of time)
function saveimage() {
var nExpenseID = {dialog.object}.getValue('ExpenseID');
if(nExpenseID == '' || nExpenseID == null)
{
alert("The app has detected that your image may not be saved. Go back to expense list and tap details to insure your image has been saved. Retake picture if needed.");
alert("This problem is due to bad connection. You need 2 or more bars");
}
var imageCtrl = {dialog.Object}.getPointer('RECEIPTIMAGE');
var photoData = imageCtrl.src;
var photoDataEnc = encodeURIComponent(imageCtrl.src);
{dialog.object}.ajaxCallback('','','xbUpdateImage','','__photoData=' + photoDataEnc,{onComplete: function() }
}
I know there are many ways to accomplish things in Alpha. Any help or suggestions would be greatly appreciated.
Comment