{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/46","labels_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/46/comments","events_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/46/events","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/46","id":110637727,"number":46,"title":"Error on Before Save and After Save at cloud code","user":{"login":"manishnath","id":907546,"avatar_url":"https://avatars.githubusercontent.com/u/907546?v=3","gravatar_id":"","url":"https://api.github.com/users/manishnath","html_url":"https://github.com/manishnath","followers_url":"https://api.github.com/users/manishnath/followers","following_url":"https://api.github.com/users/manishnath/following{/other_user}","gists_url":"https://api.github.com/users/manishnath/gists{/gist_id}","starred_url":"https://api.github.com/users/manishnath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manishnath/subscriptions","organizations_url":"https://api.github.com/users/manishnath/orgs","repos_url":"https://api.github.com/users/manishnath/repos","events_url":"https://api.github.com/users/manishnath/events{/privacy}","received_events_url":"https://api.github.com/users/manishnath/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/labels/needs%20more%20info","name":"needs more info","color":"ffeea9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-09T11:16:31Z","updated_at":"2015-10-09T21:17:13Z","closed_at":null,"body":"Using this code on beforeSave and afterSave methods, saves a blank row with no data :\r\nParse.Cloud.beforeSave(Parse.Object.extend(\"Look\"), function(request,response) {\r\n\t // Set up to modify user data\r\n \talert(\"Calling before save for look\");\r\n\r\n\t//For Expiring a look when look marked rejected\r\n\tfor (var i in request.object.dirtyKeys()) {\r\n\t\t \talert(\"Calling before save for look 1\");\r\n\r\n  \t\tvar dirtyKey = request.object.dirtyKeys()[i];\r\n  \t\talert(\"dirty key for look aftersave\"+dirtyKey);\r\n \t\tif(dirtyKey == \"eventState\" && request.object.get(\"eventState\") == 2){\r\n \t\t\t//Also expire this look\r\n \t\t\trequest.object.set(\"expired\",true);\r\n \t\t\talert(\"Look expired\");\r\n\t\t\t\r\n\t\t\tvar pushQuery = new Parse.Query(Parse.Installation);\r\n \t\t\tvar userIdQuery = new Parse.Query(Parse.User);\r\n\t\t\tvar message = \"Your look has been rejected by the event administrator.\";\r\n\t\t\tvar fromUser=request.object.get(\"fromUser\");\r\n\t\t\t\r\n\t\t\tuserIdQuery.equalTo(\"objectId\", fromUser);\r\n\r\n\t\t\tpushQuery.matchesQuery('user', userIdQuery);\r\n\t\t\tParse.Push.send({\r\n\t\t\t\t\twhere: pushQuery,\r\n\t\t\t\t\tdata: {\r\n\t\t\t\t\t\talert: message,\r\n\t\t\t\t\t\ttype:\"lookRejected\"\r\n\t\t\t\t\t}\r\n\t\t\t}, {\r\n\t\t\t\tsuccess: function() {\r\n\t\t\t\t\talert(\"Push went successfully For Look Rejection!\");\r\n\t\t\t\t},\r\n\t\t\t\terror: function(error) {\r\n\t\t\t\t\talert(\"Error executing: \" + error.code + \" \" + error.message);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n \t\t}\r\n \t}\r\n\r\n \tresponse.success();\r\n\r\n});\r\n\r\n\r\nParse.Cloud.afterSave(Parse.Object.extend(\"Look\"), function(request) {\r\n\t alert(\"Calling before save for look\");\r\n\r\n\tvar userId = request.object.get(\"fromUser\");\r\n\tvar inappropriate = request.object.get(\"inappropriate\");\r\n\tvar like = request.object.get(\"likes\");\r\n\tvar dislike = request.object.get(\"dislikes\");\r\n\tvar pushQuery = new Parse.Query(Parse.Installation);\r\n\tvar userIdQuery = new Parse.Query(Parse.User);\r\n\tvar message = \"The results are in! See what people think of your latest look.\";\r\n\tvar typeObj=\"like\";\r\n\t\t alert(\"Calling before save for look 1\");\r\n\r\n\tif(typeof dislike != \"undefined\"){\r\n\t\tlike = like + dislike;\r\n\t}\r\n\tuserIdQuery.equalTo(\"objectId\", userId);\r\n\tuserIdQuery.equalTo(\"lookResponse\", like);\r\n\r\n\t\r\n//\tif(typeof inappropriate != \"undefined\" && inappropriate != '' && inappropriate){\r\n//\t\tmessage = \"Your look has been marked inappropriate!!\";\r\n//\t\ttypeObj=\"inappropriate\";\r\n//\t}else{\r\n//\t\tuserIdQuery.equalTo(\"lookResponse\", like);\r\n//\t\tmessage = \"Hey! your looks are fetching likes!\"\r\n//\t\ttypeObj=\"like\";\r\n//\t}\r\n\r\n\t\t alert(\"Calling before save for look 2\");\r\n\r\n\tpushQuery.matchesQuery('user', userIdQuery);\r\n\tParse.Push.send({\r\n\t\t\twhere: pushQuery,\r\n\t\t\tdata: {\r\n\t\t\t\talert: message,\r\n\t\t\t\ttype:typeObj\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tsuccess: function() {\r\n\t\t\t\talert(\"Push went successfully!\");\r\n\t\t\t},\r\n\t\t\terror: function(error) {\r\n\t\t\t\talert(\"Error executing: \" + error.code + \" \" + error.message);\r\n\t\t\t}\r\n\t});\r\n\r\n\r\n});"},"comment":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/comments/146988027","html_url":"https://github.com/ParsePlatform/Parse-SDK-JS/issues/46#issuecomment-146988027","issue_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-JS/issues/46","id":146988027,"user":{"login":"parse-github-bot","id":13906986,"avatar_url":"https://avatars.githubusercontent.com/u/13906986?v=3","gravatar_id":"","url":"https://api.github.com/users/parse-github-bot","html_url":"https://github.com/parse-github-bot","followers_url":"https://api.github.com/users/parse-github-bot/followers","following_url":"https://api.github.com/users/parse-github-bot/following{/other_user}","gists_url":"https://api.github.com/users/parse-github-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/parse-github-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parse-github-bot/subscriptions","organizations_url":"https://api.github.com/users/parse-github-bot/orgs","repos_url":"https://api.github.com/users/parse-github-bot/repos","events_url":"https://api.github.com/users/parse-github-bot/events{/privacy}","received_events_url":"https://api.github.com/users/parse-github-bot/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T21:17:13Z","updated_at":"2015-10-09T21:17:13Z","body":"Thank you for your feedback.  We prioritize issues that have clear and concise repro steps.  Please see our [Bug Reporting Guidelines] (../blob/master/CONTRIBUTING.md#bugs) about what information should be added to this issue.<br /><br />Please try the latest SDK. Our [release notes](../releases) have details about what issues were fixed in each release.<br /><br />In addition, you might find the following resources helpful:<ul><li>Documentation: https://www.parse.com/docs</li><li>Google Groups: https://groups.google.com/forum/#!forum/parse-developers</li><li>Stack Overflow: http://stackoverflow.com/tags/parse.com</li></ul>"}}