2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Setting pointer value when creating a record in a collection using the service mapper

I have Accounts collection and Cards collection. Cards collection has a pointer to Accounts called accountId. I went through a few tutorials and I was able to successfully execute the Create Rest Service on Cards with the AccountId pointer populated. I am trying to do the same using the mapping and I am unable to.

On the Add Card page, I have a select box for Accounts that I am populating on load with a key of AccountId and a value of AccountName. On the data tab, I have added the add service for Card, did the mappings on the request tab. I am not sure how/what I need to map to accountId from the page. I tried adding a javascript that does

return '{"collName":"Accounts", "_id": "' + value + '"}'

but that returns a string and accountId is expecting an object since it is a pointer to Accounts collection.

Image

I am sure I am missing something basic. Please help

Thanks
Image

2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Setting pointer value when creating a record in a collection using the service mapper

By clicking on addJS next to the accountId text box on request mapping page.

Thanks

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Setting pointer value when creating a record in a collection using the service mapper

Hello! Return object, not string prereturn {"collName":"Accounts", "_id": value };/pre

2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Setting pointer value when creating a record in a collection using the service mapper

This worked. I am trying to query with a where clause and it fails. I have accountId stored in a local variable and I have the following code under "Add JS" of the where clause

return {"accountId":{"$inQuery":{"_id":value}}};

I get an error and it is complaining about where [object object]

Thanks

2fas2c
Posts: 0
Joined: Mon Dec 16, 2013 11:43 pm

Setting pointer value when creating a record in a collection using the service mapper

I figured it out. This should return a string since where clause is a string..

I changed the Javascript code to
return '{"accountId":{"$inQuery":{"_id":"' + value + '"}}}';

and it works.. Thanks

Return to “Issues”