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?
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?
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/...
I tried looking through those but I don't really understand. In the create service, should I map something to a where parameter?
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
What JS do I add to the where parameter?
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.
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?
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.
But I want it to prevent the user from creating an additional item and alert them about it.
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: