Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. // THIS METHOD IS CALLED WHEN I CLICK THE SUBMIT BUTTON
  2. $scope.handleSubmit = function() {
  3. alert($scope.currentUser); // WHY DON'T I HAVE CURRENTUSER HERE?
  4. sObj = { "sobjectType": "TargetX_SRMb__Application__c", "TargetX_SRMb__Contact__c": $scope.currentUser.ContactId };
  5. angular.forEach($scope.fields, function (f,k) {
  6. sObj[f.field_api] = f.value;
  7. });
  8. sObj.Deadline__c = $scope.deadline;
  9. sObject.upsert(sObj, {}, function (results, event) {
  10. if(event.status){
  11. angular.forEach(results, function(result, i){
  12. console.log(result);
  13. });
  14.  
  15. }else{
  16. alert(event.message);
  17. }
  18.  
  19.  
  20. });
  21. }
  22.  
  23. $scope.init = function () {
  24. $scope.calculateOptions();
  25. sObject.query("SELECT Id, ContactId FROM User WHERE Id = '{!$User.Id}'", {escape : false}, function(result, event) {
  26. $scope.currentUser = result;
  27. console.log($scope.currentUser); // THIS LOG SHOWS THAT THE OBJECT WAS SUCCESSFULLY RETRIEVED
  28. });
  29.  
  30. }
  31.  
  32. $scope.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement