• Certification Practice
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 1
    Replies
 How to insert the file related to a record in Salesforce which is in google drive?

I have successfully integrated the google drive and Salesforce and I am passing the Id of the file to get its metadata by using REST API Post call.

The response is in XML. Now I want to insert the file related to record in Salesforce.

Is this the correct way to do this? or there is any other approach to achieve this?

Any help would be highly appreciated.
How to send multiple files from REST API POST method in a single callout? Please let me know is this possible or not using apex...Or there is a way to achive this.
I have a lightning component that is updating a record and working fine when I add it to the standard Account page in lightning experience. but when I tried to embed the component on the VF page (Which runs in classic mode) and updating the records it is giving error. 
 
Is it possible to achieve it?

If yes please suggest some resources.
public class AddParentonCreateHandler {
    public static void addParentMethod(List<Student__c> stulist){
        
       
        String ParentIds ;
        Set<Id> ChildIds = New Set<Id>();
        List<Student__c> listtoupdate  = New List<Student__c>();
        List<Student__c> FinalList  = New List<Student__c>();
        List<Student__c> oldrecord = [SELECT Id,Name,Parent_Record__c,Roll_No__c FROM Student__c WHERE Parent_Record__c = null ORDER BY Roll_No__c DESC ];
        
        if(!oldrecord.isEmpty() && oldrecord.size()> 9){
            for(Student__c stu : stulist ){
                for(Student__c ostu : oldrecord){ 
                    if(stu.Name == ostu.Name ){
                        if(ChildIds.size() < 9){
                            ChildIds.add(ostu.id);  
                            
                        } 
                        else{
                            if(ParentIds ==  null){
                                ParentIds =   ostu.id;
                              
                            }
                            if(ChildIds.size() < 11  && ParentIds != null ){
                                for(Student__c stu2 : [SELECT Id,Parent_Record__c,Roll_No__c FROM Student__c WHERE ID IN : ChildIds  AND ID !=: ParentIds ORDER BY Roll_No__c DESC]){
                                    stu2.Parent_Record__c = ParentIds;
                                    listtoupdate.add(stu2);
                                }
                                
                                ChildIds.clear(); 
                                ParentIds = null;
                           }
                        }    
                    }
                } 
            }
            UPDATE listtoupdate;
        }
        
    }
}

 
How to send multiple files from REST API POST method in a single callout? Please let me know is this possible or not using apex...Or there is a way to achive this.
public class AddParentonCreateHandler {
    public static void addParentMethod(List<Student__c> stulist){
        
       
        String ParentIds ;
        Set<Id> ChildIds = New Set<Id>();
        List<Student__c> listtoupdate  = New List<Student__c>();
        List<Student__c> FinalList  = New List<Student__c>();
        List<Student__c> oldrecord = [SELECT Id,Name,Parent_Record__c,Roll_No__c FROM Student__c WHERE Parent_Record__c = null ORDER BY Roll_No__c DESC ];
        
        if(!oldrecord.isEmpty() && oldrecord.size()> 9){
            for(Student__c stu : stulist ){
                for(Student__c ostu : oldrecord){ 
                    if(stu.Name == ostu.Name ){
                        if(ChildIds.size() < 9){
                            ChildIds.add(ostu.id);  
                            
                        } 
                        else{
                            if(ParentIds ==  null){
                                ParentIds =   ostu.id;
                              
                            }
                            if(ChildIds.size() < 11  && ParentIds != null ){
                                for(Student__c stu2 : [SELECT Id,Parent_Record__c,Roll_No__c FROM Student__c WHERE ID IN : ChildIds  AND ID !=: ParentIds ORDER BY Roll_No__c DESC]){
                                    stu2.Parent_Record__c = ParentIds;
                                    listtoupdate.add(stu2);
                                }
                                
                                ChildIds.clear(); 
                                ParentIds = null;
                           }
                        }    
                    }
                } 
            }
            UPDATE listtoupdate;
        }
        
    }
}