Testing for a successful DoSync

Karl Arthur

New Member
Hi,

Is there any way to check if a DoSync was successful or not? The idea is that if a user submits a form (via a Submit and then a DoSync) and the app can't connect to the server for some reason, we would like a prompt to pop up with a Retry button asking the user to check their internet connection and click Retry or Cancel.

The error message 'Login Failed' currently pops up but I'm not sure how to check for that message. I have looked at the options in the Form Logic list and there is SyncComplete, but that doesn’t have an ‘else’ option so that I can check for a fail.

Many thanks

Karl
 

Fahim Ali

New Member
Karl,

I will bring this up with the development team to consider an else action for SyncComplete / a SyncFailed event.

For now, maybe you can try this. If you have a field that has a default value (or even blank should work fine), which you then populate with some sort of validation data of your choosing, with the OnClick event of the sync buttons. Then in the SyncComplete event, you can overwrite that field on a successful event, but if the sync does not complete, you will be able to check the validation field you set up to see that you did start a sync, but it did not finish.
 

Karl Arthur

New Member
Hi Fahim,

Thanks for your suggestion. I've tried this but I'm unable to test the value of the validation flag directly after the SyncComplete event. It's acting as if, when the sync fails, all other events underneath are ignored until another button is clicked. I have the following events:

OnClick 13 (sync button) SetValue 14 (sync success flag field) 0 (sets the default value to zero)
SyncComplete SetValue 14 (sync success flag field) 1
AfterScan 13 (sync button) If (ControlID 14=='0' ShowMessage 'sync failed'

It doesn't seem to be going through the AfterScan event and so I can't tell how to check the status of the flag directly after it fails. If I add a separate button and manually click this afterwards via an OnClick event it works fine. The user will only be clicking one button though so need to be able to check this in one go. I tried setting the 'Goto Control ID' to the ID of the separate button but it doesn't go to it for some reason.

Regards,

Karl
 

Howard Heckman III

Administrator
Staff member
Hi Karl,

Could you check against the data somehow after the sync has been attempted? For example, if you sync the record over, and it is supposed to be removed from the handheld after the sync, can you then check the record count of the session is equal to zero. So maybe something like on sync complete if record count field is greater than zero show message 'Sync failed please use the sync button to try again'.
 

Karl Arthur

New Member
Hi Howard,

Thanks for the suggestion. I added the following events to the form logic but it still doesn't work. Because the sync failed it doesn't go through the recordcount check event or the 'TEST SyncComplete' event I also added.

SyncComplete Click 21 (DBDeleteAll button to delete all records in the app's database)
SyncComplete ShowMessage 'TEST SyncComplete'
SyncComplete If (ControlID 2 > '0') ShowMessage 'Sync Failed' (control 2 is the [*recordcount*] label)

If there was some way of checking for the app's built-in error of 'login failed' I could handle it that way but can't see how to do that.

Regards,

Karl
 

Howard Heckman III

Administrator
Staff member
Hi Karl,

You may need to do something like an execute SQL action to test for the record count. I'm not sure you can check against the label like you have there.

The SQL would look like 'SELECT COUNT(*) FROM Session1'

This will place the record count of session 1 into your action control ID field. You can then use this to check for > '0'.

Let us know if this helps.
 

Karl Arthur

New Member
Hi Howard,

I've tried using the SQL action but still can't get it to go through any events after the login fails, so can't check if any records exist. I've added the following:

SyncComplete Click 21 (DBDeleteAll button to delete all records in the app's database)
LostFocus 13 (Sync button) Execute SQL 22 (a new field called DBRecordCount) SELECT COUNT(*) FROM Session1
LostFocus 13 (Sync button) if (ControlId 22 > '0') ShowMessage -1 'Sync Failed'

I've also tried AfterScan and OnClick events instead of LostFocus above.

It seems that subsequent events in the Form Logic list are ignored when the login fails until you click the submit button a second time.

Regards,

Karl
 

Howard Heckman III

Administrator
Staff member
Hi Karl,

Have you tried changing the Event to be all SyncComplete? They should be performed in sequence so if the DB Delete all is triggered on that event it should be immediately followed up with a Execute SQL, and finally the ShowMessage.

Let me know if this helps.
 
Top