Reputation: 340
I want to add a row in a class "UserPrivileges" when new user adds to _User class.
I am doing this using cloud code, so far
Parse.Cloud.afterSave(Parse.User, function(request, response) {
if (request.object.isNew()) {
var objectIdUser = request.object.objectId;
var userPrivilege = Parse.Object.extend("UserPrivileges");
var userPriv = new userPrivilege();
userPriv.set("canSubmit",true); //canSubmit is a boolean field
userPriv.save(null,{
success:function(userPriv) {
response.success(person);
},
error:function(error) {
response.error(error);
}
});
}
});
When I add new user to _User class nothing adds in "UserPrivileges", Am I missing something?
Any kind of help will be appreciated.
Upvotes: 0
Views: 153
Reputation: 173
afterSave don't have a response. If you need a response, use beforeSave.
I would make sure the "UserPrivileges" class already exists on Parse.
What's the error message you are getting?
Upvotes: 1