Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

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

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 )

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

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

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

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.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

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

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.

Return to “Issues”