Page 1 of 2

Creating a User Profile, Updating Profile, Deleting Profile

Posted: Tue Jul 08, 2014 6:01 pm
by Alex Van Name

if(profileid_label === null || profileid_label.length < 1){
profile_CreateService.execute();// run your function
}

I am not sure what the best approach is for making a conditional statement for actions.

I have made a profile page. I want new users with no profile to see a CreateService to make a new profile.

If the user has a profile already loaded in the ProfilesDataBase, I'd like to just have them update.

The problem I am having is that after the delete button(delete service) is executed.

When I add an event after the delete, for example, a LISTSERVICE, there is nothing in the ProfilesDataBase. So there are no InputFields for the user to create a new profile.

When I add an event after the delete that is a CREATESERVICE, the old data still remains...it's like there is not enough time for the data to be deleted. The input fields automatically repopulate with the old data that was displayed.

I am having a tough time, because I don't know if I should make a small javascript that should check things when a user visits the PROFILE PAGE or I should do something else, like something in the order of my Services that is wrong.

I can update the profile that exists, no problem. I just want blank input fields where there is NO PROFILE, and if there is an existing profile, I'd like to give the user the option to DELETE the Profile and immediately CREATE a new Profile. I tried running the profile_CREATESERVICE after the SUCCESS with the profile_DELETESERVICE, but this does not work, as the old data remains.

How can I fix this? Thank you


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Tue Jul 08, 2014 7:55 pm
by Evgene Karachevtsev

Hello Alex,

If you have multiple services which should work consistently (for example, delete-create-list), than you should run each subsequent on SUCCESS event of the previous one. You can also check out if there is a specified profile in the database or not (query service to the dB), and if it is not, then you should call creation service, and if there is, then call update profile service .


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Wed Jul 09, 2014 3:58 am
by Alex Van Name

this makes sense. I found the query language I should use could be :

Where {"id":{$exists":false}} -- CreateService
Where {"id":{$exists":true}} -- UpdateService

How do I call for the CreateService or UpdateService based on the conditional?


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Wed Jul 09, 2014 5:24 pm
by Evgene Karachevtsev

Hello Alex,

You should hang js code on the success of the service receive data appropriated the specified conditions. In this code, all data come in response variable data. Please check if there isn't data in data, then call service creation, otherwise update
http://devcenter.appery.io/documentat...


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Wed Jul 09, 2014 7:43 pm
by Alex Van Name

is there some special code or mapping i should do?

the where clause in the query only has room for one condition, unless I run some kind of javascript.

my problem is i cant find tutorials that really look similar, because there seems to be nothing similar in the tutorials that puts it all together


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Thu Jul 10, 2014 3:21 am
by Yurii Orishchuk

Hi Alex,

Your "where" clause looks not good.

Please read answer on this topic: https://getsatisfaction.com/apperyio/...

So, when you have your service with "where" parameter works, you need to:

1 Run this getUsers service when you need.

2 Add following code "success" event to this service:

pre

var users = data;

var usersCount = users&#46;length;

&#47;&#47;Here you can do logic in accordance to your need based on users collection&#46;
&#47;&#47;For example if count == 0 you can invoke service and if not - invoke one another&#46;

&#47;&#47;Note you need replace "usersCreateDatasource" and "usersUpdateDatasource" with your datasources on the page&#46;
if(usersCount == 0)
usersCreateDatasource&#46;execute()
else
usersUpdateDatasource&#46;execute();

/pre

Regards.


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Mon Jul 14, 2014 7:22 pm
by Alex Van Name

Dear Yuri,

Thank you so much for this. I learned BASIC when I was a child of the 1980's. I would like to make simple things work using my knowledge and your help is very much appreciated.

Thank you

Alex Van Name


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Mon Jul 14, 2014 9:56 pm
by Alex Van Name

Image

http://appery.io/app/mobile-frame?src...

I still cannot get this to work, I don't understand enough


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Tue Jul 15, 2014 2:25 am
by Alex Van Name

http://appery.io/app/mobile-frame?src...

ok i have reworked the http://appery.io/app/mobile-frame?src... a bit more, but I get these never-ending loops when I enter in a new user...there is a circle that spins and spins and spins to get data, but it doesn't stop. Can you please help me?


Creating a User Profile, Updating Profile, Deleting Profile

Posted: Tue Jul 15, 2014 2:33 am
by Alex Van Name

sometimes this works ok, but I see from the debugger there are some bad requests and I dont know why that is happening...

if the _id number for the InstructorProfile is there, why is this a bad request?

Image