Homan Mohammadi
Posts: 0
Joined: Mon Feb 17, 2014 10:30 pm

Saving data from checkbox list

Hello, we are trying see which checkboxes from a list of checkboxes were selected, and then save each selection as an entry into the database. The javascript code we are using is
Appery("mobilecheckboxgroup_11").find("input:checked").each(function(){
sharing_add.execute({data: {"collName":"users", "id":$(this).val()}});
});

The parameter we are getting from the checkbox and saving into the database (along with other information) is a pointer to the users table (in the form of their user id).

We are getting a 400 response when we submit as "Creation and modification objects with system fields not allowed."

We've checked some other responses such as getsatisfaction.com/apperyio/topics/variable_create_service_with_checkbox, but this is not working (we think it might be different because the parameter we are working with is a pointer in the database). Please let us know. Thanks!

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

Saving data from checkbox list

Hi Homan,

You are right, the problem was with the pointer collumn type.
And there is a solution:

pre
Appery("mobilecheckboxgroup_11").find("input:checked").each(function(){

Code: Select all

 var userId = $(this).val(); 
 create_dogs.execute({"data": {"_users": {"collName": "users", "_id": userId } }}); 

});
/pre

Note: don't confuse "_users" and "users".

"_users" - is your collection field name you have added as pointer to "users" pointer.

Please find more information about Pointer type here http://docs.appery.io/documentation/b...
Also we recommend to practice at creating create/update services http://docs.appery.io/documentation/b... .

Homan Mohammadi
Posts: 0
Joined: Mon Feb 17, 2014 10:30 pm

Saving data from checkbox list

Hi Alena,

Thank you for the quick response. We tried the changes you suggested, but still can't seem to get the create service to work. We still get the same 400 response. Below are the JS code and a screenshot of the collection.

JS:
Appery("mobilecheckboxgroup_11").find("input:checked").each(function(){
var userId = $(this).val();
sharing_add.execute({"data": {"users": {"collName": "users", "id": userId } }});
});

Collection:
Image

Thank you so much for your help!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Saving data from checkbox list

Hello! Do you want to add line in sharing table and fill in recipient column (pointer to Users collection), right? Then you would need to pass in service something like this presharing_add.execute({"data": {"recipient":{"collName": "users", "id": userId }}});/pre

Homan Mohammadi
Posts: 0
Joined: Mon Feb 17, 2014 10:30 pm

Saving data from checkbox list

Got it, thank you so much!

Return to “Issues”