Cor
Posts: 0
Joined: Sat Jan 25, 2014 9:17 am

passing pointervalues in requestparameters

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

passing pointervalues in requestparameters

Hi Cor -

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

Cor
Posts: 0
Joined: Sat Jan 25, 2014 9:17 am

passing pointervalues in requestparameters

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.

Cor
Posts: 0
Joined: Sat Jan 25, 2014 9:17 am

passing pointervalues in requestparameters

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.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

passing pointervalues in requestparameters

How you define the localStorage variable?

Case
Posts: 0
Joined: Mon Mar 10, 2014 12:08 am

passing pointervalues in requestparameters

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.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

passing pointervalues in requestparameters

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.

Case
Posts: 0
Joined: Mon Mar 10, 2014 12:08 am

passing pointervalues in requestparameters

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?

Case
Posts: 0
Joined: Mon Mar 10, 2014 12:08 am

passing pointervalues in requestparameters

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!

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

passing pointervalues in requestparameters

Hi Case,

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

Return to “Issues”