0

I am trying to write some Cloud Code for Parse that upon creation of a new _User, it will copy that user's objectId, append it, and then put the resulting value in a new column called SubscriptionObject. The code I have tried is:

Parse.Cloud.afterSave(Parse.User, function(request, response) {
Parse.Cloud.useMasterKey(MYMASTERKEY);  
    var theObject = Parse.User.current().id
    var newObject = 'User_' + theObject;
    request.object.set("SubscriptionObject", newObject);

    response.success();

});

However, the SubscriptionObject key never gets set.

user717452
  • 33
  • 14
  • 73
  • 149

1 Answers1

0

What does console.log('User_' + theObject); log? It may not be a string. I think it may something like "Object object"

Try using concat.

var userString = 'User_';

var newObject = userString.concat(request.user.id);

I used request.user.id because I'm not familiar with Parse.User.current().id

Unrelated, but I've never had to pass my master key into the call. I just call Parse.Cloud.useMasterKey(); Perhaps we have some differences where it is necessary. Just looking out so you don't have to publish your master key as a global variable if it's not necessary.

Troup
  • 141
  • 6
  • The console.log returns User_objectId just like I would expect it to, it's just not setting the other column in User. – user717452 Feb 17 '15 at 22:14