Page 1 of 3

how do i debug database services that fail to run correctly.

Posted: Fri Apr 18, 2014 8:45 pm
by Terry Gilliver

I have added fields to the user collection and have updated the service to include the extra fields. I have mapped the user i/f to the service. and tested. I have included an error condition when the service is run and this tells me that the user registration failed. How can I debug this to determine the point of failure.


how do i debug database services that fail to run correctly.

Posted: Fri Apr 18, 2014 9:19 pm
by Alena Prykhodko

Hello Terry,

Is it sign up service? If so, this should direct you http://docs.appery.io/tutorials/build....
Otherwise, please show us more (send us screen shots of Service settings, Request, Response tabs, mapping, a few rows from database )


how do i debug database services that fail to run correctly.

Posted: Sat Apr 19, 2014 11:36 am
by Terry Gilliver

OK. This is a database that I created, not sign up service. I include a printout of the Users collection in my database, the mappings and the service info. Image Image Image Image Image Image Image


how do i debug database services that fail to run correctly.

Posted: Sat Apr 19, 2014 11:38 am
by Terry Gilliver

I was also wondering if you could add some javascript to the error condition so that it may point to the cause of the error?


how do i debug database services that fail to run correctly.

Posted: Sat Apr 19, 2014 12:29 pm
by Terry Gilliver

I tried loading it onto my phone, and the link to the register page fails. The message is error loading page. Image


how do i debug database services that fail to run correctly.

Posted: Sat Apr 19, 2014 12:47 pm
by Illya Stepanov

Hi Terry -- As I see, you are using signup service. Please check the steps here: http://docs.appery.io/tutorials/build...


how do i debug database services that fail to run correctly.

Posted: Sat Apr 19, 2014 4:38 pm
by Terry Gilliver

Thanks Illya,

Almost there now, but getting an error message for my 'Delivery' checkbox which I have tried to map to a boolean in the database. It doesn't seem to like 'false' as being passed to the DB. Also my back button on my registry screen doesn't work and neither does the cancel button which has a navigate to page action on it. This may of course be due to the data mapping error.

Am I using the right variable type in the database?
what values should be given to the checkbox for true and false?
If I click the checkbox will its value be automatically changed or will I have to change it in Javascript?

Thanks for you help
Terry


how do i debug database services that fail to run correctly.

Posted: Mon Apr 21, 2014 4:03 am
by Illya Stepanov

Hi Terry,

Currently you are in right direction.

But let us a help you a little bit.
ol
liYou can debug your application with browser build-in debugger./li
/ol
ul
li1.1 Run your app in desktop chrome browser./li

li1.2 Click F12 to open it. http://prntscr.com/3bymgp/direct/li

li1.3 Click on the Network tab. http://prntscr.com/3bymqk/direct/li

li1.4 Then run your application and try to register./li

li1.5 You will see in your network debugger a request to the "...../users"/li

li1.6 Open it and discover. There is all information about communication with server. (request headers, parameters, response headers response body etc..)/lili

http://prntscr.com/3bynxh/direct

http://prntscr.com/3byojw/direct
/li/ul
So, this way you can debug your requests and know about reason of the error.

What about "boolean" field type. You should return only boolean type.

So, click "edit JS" and enter the following code:
precode
//You should specify your condition in accordance to logic you need.
if(value = "true")
return true;

return false;code/code/code/pre
That's all.


how do i debug database services that fail to run correctly.

Posted: Wed Apr 23, 2014 2:51 pm
by Terry Gilliver

Thanks Illya, still having issues,

  1. I notice that a couple of the calls on the network stack return a status of 304- not modified. I assumed that every status other than 200 is an error condition. Am I right?

  2. I am still not sure of the syntax for the js on the checkbox. The next few lines is taken from the javascript sent:

    /*

    • Nonvisual components
      */
      var datasources = [];

      restservice1 = new Apperyio.DataSource(DougiesDB_signup_service, {
      'onBeforeSend': function(jqXHR) {

      },
      'onComplete': function(jqXHR, textStatus) {

      Code: Select all

       Apperyio.refreshScreenFormElements("RegistrationScreen"); 

},
'onSuccess': function(data) {
Apperyio.navigateTo('LoginScreen', {
reverse: false
});
},
'onError': function(jqXHR, textStatus, errorThrown) {
var response = JSON.parse(jqXHR.responseText);
alert(response.description);
},
'responseMapping': [{
'PATH': ['id'],
'ID': 'local_storage',
'ATTR': 'userid'
}, {
'PATH': ['sessionToken'],
'ID': 'local_storage_',
'ATTR': 'userSessionToken'
}],
'requestMapping': [{
'PATH': ['X-Appery-Database-Id'],
'TYPE': 'STRING',
'HEADER': true,
'ATTR': '{database_id}'
}, {
'PATH': ['username'],
'TYPE': 'STRING',
'ID': 'Username',
'ATTR': 'value'
}, {
'PATH': ['password'],
'TYPE': 'STRING',
'ID': 'Password',
'ATTR': 'value'
}, {
'PATH': ['FirstName'],
'TYPE': 'STRING',
'ID': 'Firstname',
'ATTR': 'value'
}, {
'PATH': ['LastName'],
'TYPE': 'STRING',
'ID': 'Lastname',
'ATTR': 'value'
}, {
'PATH': ['Address1'],
'TYPE': 'STRING',
'ID': 'AddressLine1',
'ATTR': 'value'
}, {
'PATH': ['Address2'],
'TYPE': 'STRING',
'ID': 'AddressLine2',
'ATTR': 'value'
}, {
'PATH': ['Postcode'],
'TYPE': 'STRING',
'ID': 'Postcode',
'ATTR': 'value'
}, {
'PATH': ['Email'],
'TYPE': 'STRING',
'ID': 'EmailAddress',
'ATTR': 'value'
}, {
'PATH': ['Delivery'],
'TYPE': 'STRING',
'ID': 'Delivery',
'ATTR': 'value',
'TRANSFORMATION': function(value) {
if ($("#RegisterScreen_Delivery").checked) {
$("#RegisterScreen_Delivery").val = true;
} else {
$("#RegisterScreen_Delivery").val = false;
}
}
}]
});

Code: Select all

 datasources.push(restservice1); 

I am guessing that is still not quite right as the following are the response headers after clicking register:

Request URL:https://api.appery.io/rest/1/db/users
Request Headers CAUTION: Provisional headers are shown.
Accept:application/json, text/javascript, /; q=0.01
Content-Type:application/json
Origin:http://appery.io
Referer:http://appery.io/app/view/3bf3be04-f5...
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36
X-Appery-Database-Id:53514a80e4b0e44dd02714be
Request Payloadview source
{username:tommy2, password:ravine, FirstName:Terry, LastName:Gilliver, Address1:hgjhg,...}
Address1: "hgjhg"
Address2: "jhgjhgjh"
Delivery: "false"
Email: "a href="mailto:terry@mrtaxsoftware.com" rel="nofollow"terry@mrtaxsoftware.com/a"
FirstName: "Terry"
LastName: "Gilliver"
Postcode: "LE65 2NY"
password: "ravine"
username: "tommy2"

This clearly shows that value of Delivery is till false even though I clicked the checkbox, so there is an error in my javascript somewhere. Also what does the Caution at the top of the header mean?

Thanks, Terry


how do i debug database services that fail to run correctly.

Posted: Wed Apr 23, 2014 5:42 pm
by Terry Gilliver

Think I've almost got it with the following js:

var checkbox = $('input',Appery('Delivery'));
if (checkbox.prop('checked')) {
checkbox.val(true);
} else {
checkbox.val(false);
}

alert("value = " + checkbox.val());

This seems to load the value of the checkbox with true or false, but when I check the Database it always reports false.