• Andrew Posadzy
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am looking for a way to link Salesforce and Amazon S3. I am looking at launching a lightning community and very well could reach the salesforce storage limits. Therefore, I need a way to have those files in the community be stored in S3 and not in salesforce. Does any know of any apps that can do this or of any apex related solutions. 
I am trying to create a trigger that assigns a profile to a customer that will give them access to a SF community. 

Trigger
trigger Assign_Customer_Community_User on Contact (after insert, after Update) {
	set<user> usersId = new set<user>();
    set<id> contactIdsSet = new set<id>();
    
    for (contact c : trigger.new) {
        
        List<OrderAPI__Badge__c> contactBadge = [SELECT id, OrderAPI__Badge_Type__c, OrderAPI__Contact__c FROM OrderAPI__Badge__C WHERE OrderAPI__Contact__c = :c.id];
        
        for (OrderAPI__Badge__c b : contactBadge) {
            if (b.OrderAPI__Badge_Type__c == 'a0k1g000000n4vLAAQ') {
                contactIdsSet.add(c.id);
            } else {
                //do nothing
            }
        }  
    }
    
    For(User usr : [SELECT Id FROM User WHERE ContactID!=null AND ContactId IN : contactIdsSet]) {
        usersId.add(usr);
    }
    
    Assign_Customer_Community_User.AssignProfileToUser(usersId);
    
    
    
    
}

Class
public class Assign_Customer_Community_User {

    public static void assignProfileToUser(set<User> userIds) {
        list<User> updatedUserlst = new list<User>();
        profile p = [SELECT ID FROM profile WHERE name = 'Customer Community User'];
        if (userIds.size() > 0 && userIds !=null) {
            for (user u : userIds) {
                u.profileId = p.id;
                updatedUserlst.add(u);
            } 
        }
        updatedUserlst.addAll(userIds);
        
        update updatedUserlst;
    } 
}

 
I am trying to create a trigger that assigns a profile to a customer that will give them access to a SF community. 

Trigger
trigger Assign_Customer_Community_User on Contact (after insert, after Update) {
	set<user> usersId = new set<user>();
    set<id> contactIdsSet = new set<id>();
    
    for (contact c : trigger.new) {
        
        List<OrderAPI__Badge__c> contactBadge = [SELECT id, OrderAPI__Badge_Type__c, OrderAPI__Contact__c FROM OrderAPI__Badge__C WHERE OrderAPI__Contact__c = :c.id];
        
        for (OrderAPI__Badge__c b : contactBadge) {
            if (b.OrderAPI__Badge_Type__c == 'a0k1g000000n4vLAAQ') {
                contactIdsSet.add(c.id);
            } else {
                //do nothing
            }
        }  
    }
    
    For(User usr : [SELECT Id FROM User WHERE ContactID!=null AND ContactId IN : contactIdsSet]) {
        usersId.add(usr);
    }
    
    Assign_Customer_Community_User.AssignProfileToUser(usersId);
    
    
    
    
}

Class
public class Assign_Customer_Community_User {

    public static void assignProfileToUser(set<User> userIds) {
        list<User> updatedUserlst = new list<User>();
        profile p = [SELECT ID FROM profile WHERE name = 'Customer Community User'];
        if (userIds.size() > 0 && userIds !=null) {
            for (user u : userIds) {
                u.profileId = p.id;
                updatedUserlst.add(u);
            } 
        }
        updatedUserlst.addAll(userIds);
        
        update updatedUserlst;
    } 
}