Page 4 of 12

Is it possible to have the same button run both a create service and an update service?

Posted: Tue Dec 09, 2014 1:55 pm
by Ellen Schlechter

The error is in this line of code.
var isCreated = data.length 0; // this expression will return true or false


Is it possible to have the same button run both a create service and an update service?

Posted: Wed Dec 10, 2014 1:59 am
by Ellen Schlechter

Now in addition to the error above, I get this.
Image Image


Is it possible to have the same button run both a create service and an update service?

Posted: Wed Dec 10, 2014 5:50 am
by Yurii Orishchuk

HI Ellen,

In this case - you have "data" variable with undefined value. Thus you have this problem.

Regards.


Is it possible to have the same button run both a create service and an update service?

Posted: Wed Dec 10, 2014 2:04 pm
by Ellen Schlechter

What is that? I just used the code you gave me.


Is it possible to have the same button run both a create service and an update service?

Posted: Wed Dec 10, 2014 2:35 pm
by Evgene Karachevtsev

Hello Ellen,

If where parameter in request hasn't valid value, response has in description "Incorrect query".

Code that support team provides, can be used as example and each case should be modified, there is no real use case, when you can copy code without changing/adding something.


Is it possible to have the same button run both a create service and an update service?

Posted: Wed Dec 10, 2014 5:03 pm
by Ellen Schlechter

This is what I have. Should something be changed? Image


Is it possible to have the same button run both a create service and an update service?

Posted: Thu Dec 11, 2014 10:46 am
by Evgene Karachevtsev

Ellen,

1) Value from that javascript should be returned as a string, so the mapping could use it for you 'where' parameter
2) Instead of "hereisYourUserIdYouWantToTest", obviously ,you need to put id


Is it possible to have the same button run both a create service and an update service?

Posted: Thu Dec 11, 2014 6:53 pm
by Ellen Schlechter

So I simply changed "hereisYourUserIdYouWantToTest" to "id" and it didn't change anything.


Is it possible to have the same button run both a create service and an update service?

Posted: Thu Dec 11, 2014 7:18 pm
by Egor Kotov6832188

Hello Ellen.
Id of each collection looks like "5489e282e4b05c4ac3be8869".
You are trying to search for users in your collection. Id(identifier) is a unique sequence of numbers and characters, that makes one item(entity) different to another within one collection or Database(depending on Database).
So you need somehow(local variable, mapping, component on the page) store it for users, and get one of them before sending request for searching user by it's id in this where parameter. Don't forget that you can't simply set where parameter value to user id, you need to point that it is column id and return it to the where parametr
IT IS JUST AN EXAMPLE, NOT YOUR USER'S ID
return '{"_id": "5489e282e4b05c4ac3be8869"}';


Is it possible to have the same button run both a create service and an update service?

Posted: Thu Dec 11, 2014 8:22 pm
by Ellen Schlechter

Ohh now I understand! I already have an _id mapped to a label so would I just put the name of the label there?