Page 1 of 1

saving active users userid not working

Posted: Mon Jun 02, 2014 12:36 pm
by Jamie Steiner6905824

Hi,

I have a create service that runs some javascript to create a record. It all works except for one mapping: the userid of the logged in user (stored in local variable = UserID. I tried the following javascript, which I think should work:

var UserID = localStorage.getItem('UserID');
return '{"collName": "users", "id": "' + UserID + '"}';

When I test it in the createservice window using:

{"collName": "users", "id": "5389cb82e4b0a73d895c8844"} (having replaced the UserID variable with an actual _id, it works. I also know the .getItem call is working, because I can see it if I put it in an alert.

I have tried setting it up with a mapping and using "'+ value +'" and also without the mapping, with the .getItem call....


saving active users userid not working

Posted: Mon Jun 02, 2014 1:31 pm
by Evgene Karachevtsev

Hello Jamie,

Please, clarify your problem. Are you going to create record in DB with field type pointer? What doesn't work exactly?


saving active users userid not working

Posted: Mon Jun 02, 2014 2:36 pm
by Jamie Steiner6905824

Yes, you have described it. This value goes into a field in a pointer column. The value does not get put in, and the entire record is not created.


saving active users userid not working

Posted: Mon Jun 02, 2014 6:48 pm
by Jamie Steiner

nevermind, I figured it out:

var UserID = localStorage.getItem('UserID');
var temp = {"collName": "users", "id": UserID};
return temp;

Strange that the syntax I used previously didn't work.


saving active users userid not working

Posted: Mon Jun 02, 2014 7:05 pm
by Kateryna Grynko

Hi Jamie,

Glad you solved it. Thank you for the update!