Mike Cardosa
Posts: 0
Joined: Thu Aug 08, 2013 1:55 am

Create a row with a pointer to a user

Hello,

I have a collection called categories that has two non-default columns: category_name and user_id. In my app, I'd like to let users create categories that only they can see. I have login working and I am storing both the sessionToken and userID in local variables. When I try to create a new row from the app, I get this error:

"Pointer column value of field 'user_id' must be JSON object but has 'class java.lang.String'"

How am I supposed to pass the userID back to the service? Once it is set, I would be able to build the queries based on the logged in user.

Thanks

Image

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Create a row with a pointer to a user

Hi Mike,

Try for user_id param:
precode{ "collName": "user", "id": "51efd..." }/code/pre

More details you can find here.

Mike Cardosa
Posts: 0
Joined: Thu Aug 08, 2013 1:55 am

Create a row with a pointer to a user

Thanks. That works when I test. Now how do I actually get the form to use that format when it is submitted?

Image

Mike Cardosa
Posts: 0
Joined: Thu Aug 08, 2013 1:55 am

Create a row with a pointer to a user

I figured it out. I added the following JS to the user_id variable in the request:

var userID = localStorage.getItem('userID');
var user_json = {
"collName" : "user",
"id" : userID
};
return user_json;

Return to “Issues”