public string CreateGroup(String name, String descriptioon, string ownerEmployeeId) { if (_service == null) { throw new Exception("Service is null. You need to login first!"); } if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(ownerEmployeeId)) { throw new Exception("Invalid argument!"); } Salesforce.User user = GetUser(ownerEmployeeId); Salesforce.CollaborationGroup grp = new Salesforce.CollaborationGroup() { Name = name, Description = descriptioon, OwnerId = user.Id, CollaborationType = "Private" }; Salesforce.SaveResult[] results = _service.create(new Salesforce.sObject[] { grp }); foreach (Salesforce.SaveResult result in results) { if (!result.success) { throw new Exception(result.errors.Select(it => it.statusCode + ":" + it.message).Aggregate((s1, s2) => s1 + "\n" + s2)); } } return(results[0].id); }
public void AddUsersToGroup(String groupId, string[] users) { if (_service == null) { throw new Exception("Service is null. You need to login first!"); } if (string.IsNullOrEmpty(groupId) || users == null || users.Length == 0) { throw new Exception("Invalid argument!"); } Salesforce.sObject[] objects = new Salesforce.sObject[users.Length]; for (int i = 0; i < users.Length; i++) { Salesforce.User user = GetUser(users[i]); objects[i] = new Salesforce.CollaborationGroupMember() { CollaborationGroupId = groupId, MemberId = user.Id }; } Salesforce.SaveResult[] results = _service.create(objects); foreach (Salesforce.SaveResult result in results) { if (!result.success) { throw new Exception("Cannot create GroupMember for group id=" + groupId + ", with error:\n" + result.errors.Select(it => it.statusCode + ":" + it.message).Aggregate((s1, s2) => s1 + "\n" + s2)); } } }
protected void CreateResearchProfileInternal(string employeeId) { if (_service == null) { throw new Exception("Service is null. You need to login first!"); } if (string.IsNullOrEmpty(employeeId)) { throw new Exception("Invalid argument!"); } Salesforce.User user = GetUser(employeeId); Salesforce.Research_Profile__c profile = new Salesforce.Research_Profile__c { Name = user.FirstName + " " + user.LastName + " Research Profile", OwnerId = _userId, User__c = user.Id }; Salesforce.SaveResult[] results = _service.create(new Salesforce.sObject[] { profile }); foreach (Salesforce.SaveResult result in results) { if (!result.success) { throw new Exception("Cannot create ResearchProfile for employee id=" + employeeId + ", with error:\n" + result.errors.Select(it => it.statusCode + ":" + it.message).Aggregate((s1, s2) => s1 + "\n" + s2)); } } }
public string GetUserId(string employeeId) { Salesforce.User user = GetUser(employeeId); return(user.Id); }