• Shajadi shaik
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
public class CaseTriggerHandler {
    
    public static void handleAfterupdate(List<Case> newCase){
        List<Case> caseListToUpdate = new List<Case>(); // listing out the updated data of cases in a object
        List<Case> brandRelatedCase = new List<Case>(); // listing out the brand related cases in a object
        System.debug('**********'+newCase);
        Set<Id> caseIDs = new Set<Id>();
        Integer userListSize;
        Map<Id,List<User>> mapUsersList = new Map<Id,List<User>>();
        List<User> mapRRList = new List<User>();

        String amesUsers = System.Label.Ames_Round_Robin_Users;
        List<String> amesUsersList = amesUsers.split(';');
        System.debug('amesUsersListamesUsersList'+amesUsersList);
        List<User> userList = [SELECT id,Name,isActive,LastLoginDate,Round_Robin_Number__c FROM User WHERE Email IN:amesUsersList AND isActive = TRUE AND LastLoginDate >=:System.today()
                                ];
        System.debug(userList.size()+'useruseruseruser'+userList);
        userListSize = userList.size();
        for(User userVal:userList){
            
            mapRRList.add(userVal);
            
        }
        
        List<Ames_Round_Robin_Users__mdt> amesRR = [SELECT Label,OwnerID__c,Queue_Number__c from Ames_Round_Robin_Users__mdt];

        
        for(Case newCaseList:newCase){
            if(newCaseList.Id != null){
                brandRelatedCase.add(newCaseList);
            }
        }
        
        List<User> updateRRUser = new List<User>();
        if(!brandRelatedCase.isEmpty()){
            for(Case newCaseList:brandRelatedCase){
                System.debug('newCaseListnewCaseListnewCaseList'+newCaseList.Brand__c);
                Integer caseCountVal = Math.MOD(Integer.valueOf(newCaseList.Case_RR_Number__c) ,userListSize);
                System.debug('caseCountValcaseCountValcaseCountVal'+caseCountVal);
                for(Ames_Round_Robin_Users__mdt amesRRList: amesRR){
                    if(newCaseList.Brand__c != null && newCaseList.Brand__c == 'AMES'){
                        if(amesRRList.Queue_Number__c == caseCountVal){
                            newCaseList.OwnerID = amesRRList.OwnerID__c;
                        }                        
                    }                    
                }                
                System.debug('newCaseListnewCaseList'+newCaseList);
            }            
        } 
    }
}
Hi, I am a newbie to salesforce knowledge and I have been trying to publish articles to salesforce lightning knowledge via REST API. I am having trouble figuring out the way to add an image in rich text field areas in articles via APIs for a while now. From the UI,  when I click the image option in the UI, it creates a link like this

<img alt="" src="https://c.ap17.content.force.com/servlet/rtaImage?eid=ka02x0000005Qny&feoid=00N2x000000xPaN&refid=0EM2x000000PW60" />

I could not figure out how to upload articles to this servlet and get back a similar URL as a response, so that I can use these links in rich text areas. Can someone point me in the right direction?

Thanks,
Rajasekhar
Hello,

I want to add a button to my Product2 object that lets a user upload a photo of the product. I would like the image URL be stored automatically in a field on the Product2 record after uploading. I am guessing that to achieve this, I need to make some kind of visualforce widget for uploading the image, tie that to the action of a button on the object, and then have some kind of workflow rule or apex trigger fire after the image is uploaded and enter its URL into the field. What is the easiest way to do this?

Hello all,

I found some code on how to create an Apex Class that allows users to send an email to salesforce with a specific subject format to create tasks.

The problem is that this code seems to be a little old and I'm having some trouble updating it as I'm not overly familiar with Apex coding. 

 

global class clsInboundEmailHandler implements Messaging.InboundEmailHandler { 

	global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env){ 
		Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); 
			
			string subject = email.Subject; 
			string userID = ''; 
			integer userIDNumber = 0; 
			string restOfSubject = ''; 
			if(subject.contains('-') == false){ 
				result.success = false; 
				return result; 
			} 
			list<String> subjectSplit = new list<String>(); 
			subjectSplit = subject.split('-'); 
			userID = subjectSplit[0]; 
			userID = userID.trim(); 
			if(userID.isNumeric() == false){ 
				result.success = false; 
				return result; 
			}else{ 
				userIDNumber = integer.valueOf(userID); 
			} 
			boolean firstOne = true; 
			for(string s : subjectSplit){ 
				if(firstOne){ 
						firstOne = false; 
					}else{ 
						restOfSubject += s; 
					} 
				} 
				
				//Now find the user 
				string userIDForTask = getUserIDForTask(userIDNumber); 
				if(userIDForTask == ''){ 
					result.success = false; 
					return result; 
				} 
				
				Task t = new Task(); 
				t.Subject = restOfSubject; //This is from the subject line 
				t.ActivityDate = date.today(); 
				t.Description = email.plainTextBody; //or email.htmlbody; 
				t.Priority = 'Normal'; 
				t.OwnerId = userIDForTask; //Set to owner 
				t.Status = 'Not Started'; 
				t.IsReminderSet = true; 
				t.ReminderDateTime = System.now() + 1; 
				insert t; 
				
				result.success = true; 
				return result; 
			} 
			
			private string getUserIDForTask(integer userIDNumber){ 
				list<boolean> userList = new list<boolean>(); 
			string userIDForTask = ''; 
			userList = [Select ID 
								From User 
								Where EmailTaskID__c = :userIDNumber]; 
			if(userList.size() <> 1){ 
				return ''; 
				}else{ 
					return userList[0].id; 
				} 
			} 
		}

The problem is at line 58, I am getting the error "Illegal assignment from List to List". I believe the error is related to the way userIDNumber is declared, but for the life of me I cannot figure out the solution.

Would anyone have any suggestions or a solution?

Thank you.