0
votes

When a user signs up I need to add a row to another class (class B) with a reference pointer to this user and add a reference to the user class that points to the newly created row in class B.

Is there a way to get the Parse.User id in an beforeSave action?

If not what would be a way to achieve this with cloud code?

1
sorry for the late reply. thanks, this helped. - florian norbert bepunkt

1 Answers

2
votes

beforesave the row didnt created yet, so you cant do pointer to something that still dont exist, and maybe error occur and the user never will create. In this case you have to use aftersave.

Do it with aftersave trigger

Parse.Cloud.afterSave(Parse.User, function(request) {
  var user = request.object;
  var ClassB = Parse.Object.extend("ClassB");
  var classb = new ClassB();
  classb.set("user", user);
  ....
  classb.save();
  ....
});