• Komal Dhiman
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi everyone
I am writing a trigger on after insert.
This trigger will set the photo of user that is inserted.
But i am getting this error on creation of user.
My trigger handler class is
public without sharing class UserTriggerHandler{
     public static void uploadPhoto(List<User> userList){
        Document document=[SELECT Id,Body,DeveloperName FROM Document WHERE Document.DeveloperName='User_Logo'];
        for(User user:userList){
            Blob b= document.Body;
            String communityId = null;
            ConnectApi.Photo photo = ConnectApi.UserProfiles.setPhoto(communityId, user.Id, new ConnectApi.BinaryInput(b, 'image/jpg', 'userImage.jpg'));
        }
    }
}

My trigger is
trigger UserTrigger on User (after insert) {
    if (Trigger.isAfter && Trigger.isInsert) {
        UserTriggerHandler.uploadPhoto(Trigger.new);
    }
}
Code:
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name RETURNING Leads(Name),Contact(FirstName,LastName)];
    }
}
I am just trying to return Lead and Contact object where name contains the string passed to this method.
Code:
public class ContactAndLeadSearch{
    public static List<List<SObject>> searchContactsAndLeads(String name){
       return [FIND :name IN Name RETURNING Leads(Name),Contact(FirstName,LastName)];
    }
}
I am just trying to return Lead and Contact object where name contains the string passed to this method.