Muhammad Awais
Muhammad Awais

Reputation: 340

Adding a relation row in a class when new user add to _User Parse

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

Answers (1)

Chaitanya Shah
Chaitanya Shah

Reputation: 173

  1. afterSave don't have a response. If you need a response, use beforeSave.

  2. I would make sure the "UserPrivileges" class already exists on Parse.

  3. What's the error message you are getting?

Upvotes: 1

Related Questions