Page 1 of 2

Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Sat Feb 07, 2015 4:41 am
by Ellen Schlechter

I have a form that a user fills out and it saves it in the database. They assign a specific name to it so is it possible to have a notification to let them know that that have already created something with that name?


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Sat Feb 07, 2015 5:36 am
by Alena Prykhodko

Hello,

It would need to be implemented in your app logic. For example, you could check if such record already exists in the database and then call the create service in your JavaScript.

These threads should be useful: https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Sat Feb 07, 2015 3:13 pm
by Ellen Schlechter

I tried looking through those but I don't really understand. In the create service, should I map something to a where parameter?


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Mon Feb 09, 2015 10:44 pm
by Egor Kotov6832188

Hello Ellen.

Create service only creates entity in DB, it doesn't do anything else.
If you want to check one or many columns on their uniqueness, then you need before each calling create service invoke FIND(query) service with where parameter , where you can check input value

1) Add query service to the page
2) add js to where parameter
3) on success event for query service add js
if (data.length == 0) {
createService.execute({});
}

Code above will check if result is 0 , thus entity with such name wasn't found, this means you can call your create service.
Don't forget to write real name of your service on the page

Note:
createService.execute({}); - this line will invoke your create service with mapping


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Mon Feb 09, 2015 10:58 pm
by Ellen Schlechter

What JS do I add to the where parameter?


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Thu Feb 12, 2015 12:23 am
by Yurii Orishchuk

Hi Ellen,

You should use there custom JS that will form filter that you need to make sure your collection contains goal item or not..

Regards.


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Thu Feb 12, 2015 1:20 am
by Ellen Schlechter

So use this JS:
if (data.length == 0) {
createService.execute({});
}
and it goes in the 'where' parameter of the before send of my create service?


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Fri Feb 13, 2015 3:12 am
by Yurii Orishchuk

Hi Ellen,

Nope, this code should be placed in "list/query" service "Success" event.

It will invoke "createService" after you list service will get 0 items as result.

Regards.


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Fri Feb 13, 2015 3:33 am
by Ellen Schlechter

But I want it to prevent the user from creating an additional item and alert them about it.


Is there a way to notify a user if they try to create something that they have already created based on one certain colu

Posted: Fri Feb 13, 2015 10:42 am
by Evgene Karachevtsev

Hello Ellen,

We completely understand your situation. But to prevent the user from creating an additional item you will need to consistently implement 2 steps:

  1. add js to the where parameter of the FIND(query) service, this js have to realize searching by user inputted data
  2. on success event for query service add js
    if (data.length == 0) {
    createService.execute({});
    }
    where data will contain the result of searching in the where parameter of the FIND(query) service. if your data will empty, it means that user inputted is unique and you could create new user.