Page 1 of 1

passing pointervalues in requestparameters

Posted: Sat Jan 25, 2014 9:17 am
by Cor

Hi,

I created a local storage variable with a pointer value. Now i want to pass this pointervalue in a requestparameter of a create service by mapping it to the proper requestparameter of the approrpriate pointertype. This does not work because it seems that the mapped pointer is not a JSON object.
What am I doing wrong? Is it not just possible to map a local storage variable with a pointer value to a create requestparameter of a pointertype?

thanks in advance, Cor


passing pointervalues in requestparameters

Posted: Sat Jan 25, 2014 9:27 am
by Illya Stepanov

Hi Cor -

Can you post more information: your mapping structure, the value of the pointer stored in localStorage, errors that you get?


passing pointervalues in requestparameters

Posted: Sat Jan 25, 2014 9:58 am
by Cor

Hi,

The error i get on InspectElement--Network from Chrome is :

code: "DBSC241"
description: "Pointer column value of field 'Dossier' must be JSON object but has 'class java.lang.String'"

The Request header is:

.......
X-Appery-Session-Token:93091d39-4f5c-427b-a163-0dc05b4da44c
Request Payloadview source
{Dossier:52e27763e4b0ba319afe733c, acl:{:{write:true, read:true}}}
Dossier: "52e27763e4b0ba319afe733c"
acl: {:{write:true, read:true}}
Response Headersview source
Access-Control-Allow-Origin:http://appery.io
Connection:keep-alive
......

This is after I mapped a localStorage parameter CurrentContext with value:

localStorage.CurrentContext
"52e27763e4b0ba319afe733c"

to a Request Parameter of a create service with the appropriate (Dossier) type.


passing pointervalues in requestparameters

Posted: Sat Jan 25, 2014 9:59 am
by Cor

Hi,

The error i get on InspectElement--Network from Chrome is :

code: "DBSC241"
description: "Pointer column value of field 'Dossier' must be JSON object but has 'class java.lang.String'"

The Request header is:

.......
X-Appery-Session-Token:93091d39-4f5c-427b-a163-0dc05b4da44c
Request Payloadview source
{Dossier:52e27763e4b0ba319afe733c, acl:{:{write:true, read:true}}}
Dossier: "52e27763e4b0ba319afe733c"
acl: {:{write:true, read:true}}
Response Headersview source
Access-Control-Allow-Origin:http://appery.io
Connection:keep-alive
......

This is after I mapped a localStorage parameter CurrentContext with value:

localStorage.CurrentContext
"52e27763e4b0ba319afe733c"

to a Request Parameter of a create service with the appropriate (Dossier) type.


passing pointervalues in requestparameters

Posted: Sat Jan 25, 2014 12:14 pm
by Illya Stepanov

How you define the localStorage variable?


passing pointervalues in requestparameters

Posted: Thu Apr 03, 2014 1:30 am
by Case

I am getting this same error. localStorage value for userID is saved during login. I am using that same localStorage value to map to my pointer column in service request.


passing pointervalues in requestparameters

Posted: Thu Apr 03, 2014 3:13 am
by Illya Stepanov

Hi Case,

If you want to update pointer DB field with updated service you have to:
ol
liOpen service mapping./li
liFind your request field with pointer type./li
liClick "Add JS"/"Edit JS"./li

liAnd fill JS editor by following code:
precode
//entityId - is id which is you want to store in pointer field.
var entityId = "52fe1b55e4b0a25c11c899de&quot

//users - is a collection name pointer points to..
return {collName: "users", "_id": entityId};
/code/pre/li
/ol
Note: You have to set "entityId" by your id. If you are using mapping to this field you can use "value" variable for this purpose.

Also you need to set collName by collection name pointer points to.

Regards.


passing pointervalues in requestparameters

Posted: Thu Apr 03, 2014 4:57 am
by Case

Thanks Illya, this clarifies why I was getting the error as I was passing a single string and not an array that includes the "_id". I'm still not 100% sure what you mean by using "value" variable, but I understand the intention.

Should I:
var entityId = localStorage.getItem('my_variable');

or is {value} a variable if I actually drag the arrow to map it?


passing pointervalues in requestparameters

Posted: Thu Apr 03, 2014 5:04 am
by Case

var entityId = localStorage.getItem('my_variable'); seems to work great! I did need to name my collName "_users" for it to pull properly - Thanks for the help!


passing pointervalues in requestparameters

Posted: Thu Apr 03, 2014 5:16 am
by Kateryna Grynko

Hi Case,

Thank you for the update! Glad it's working.