Jamie Steiner6905824
Posts: 0
Joined: Sun Jun 01, 2014 10:16 am

saving active users userid not working

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....

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

saving active users userid not working

Hello Jamie,

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

Jamie Steiner6905824
Posts: 0
Joined: Sun Jun 01, 2014 10:16 am

saving active users userid not working

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.

Jamie Steiner
Posts: 0
Joined: Sun Jun 01, 2014 10:06 am

saving active users userid not working

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

saving active users userid not working

Hi Jamie,

Glad you solved it. Thank you for the update!

Return to “Issues”