Mahammad Adil Azeem
Mahammad Adil Azeem

Reputation: 9392

Getting objects from Parse Relation that were added in this save

I have a Parse Class Group and there is a parse relation field in it, called people (users, who are in this group). I am implementing a afterSave on "Group". I want to notify users, who are just added by admin into this group.

How do i do that ?

 Parse.Cloud.afterSave(Group, function(request){
  Parse.Cloud.useMasterKey();

  var group = request.object;
  var relation = group.relation("people");

  //How to get users that are added on this save.

});

Upvotes: 1

Views: 94

Answers (1)

Mo Nazemi
Mo Nazemi

Reputation: 2717

To find the new records being added to a relation, you need to inspect the relationsToAdd property of a Relation (its an array):

var newRecords = request.object.op("people").relationsToAdd;

I know this works in beforeSave but have not used it in afterSave tirggers

Upvotes: 2

Related Questions