• Sachin Patil 57
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi,
I am in part whereI need to get the failed records in a CSV. I am able to get the failed records into a CSV but the records are coming with the fieldNames as I have added the screenshot below.  But I dont want the fields coming with the field Names and object Name.User-added imagePlease Someone help me in getting only the record values

Thanks in Advance
Sachin

Hi all,
I have a task to create a table where i should iterate through 2 lists(dynamic lists). I have used Wrapper class for lists. Below is the code that I have used.
Please someone help me with the code below

*************VisualForce Page**************

<apex:pageBlockSection columns="2"  >
                <apex:pageBlockTable value="{!wrapLists}" var="wrap">
                    <apex:column headerValue="API Names" value= "{!wrap.APINamesList}" />
                    <apex:column headervalue="CSV Fields" value="{!wrap.allCSVFields}" />  
                </apex:pageBlockTable>
            </apex:pageBlockSection> 


*********Controller************

public void getApiNames(){ 	
       wrap = new wrapperClass();
        queryResults = [SELECT API_Names__c,Object__c,Label FROM dataload__mdt WHERE Label= :selectedFunction ];
        allAPINames = queryResults[0].API_Names__c;
        wrap.APINamesList = new List<string>();
        APIList= new List<String>();
        wrapLists.clear();
            for(string APINames: allAPINames.split(',')){
            APINamesMap.put(APINames, APINames);
            system.debug('Test2'+APINames);
            
          wrap.APINamesList.add(APINames);
            System.debug('TEster'+wrap.APINamesList);
              wrapLists.add(wrap);
           // APIList.add(APINames);
        }  
             
    }
    
    Public void saveFile(){
        for(string sac: APIList){
            if(CSVList.contains(sac)){
                insert objDataLoader;
        objAttachment.ParentId = objDataLoader.id;
        insert objAttachment;
            }
        }
        
    }
    
    Public void readcsvFile(){
        CSVList= new List<string>();
        csvFileLines = new List<String>{};
        wrap.allCSVFields= new List<String>();
        wrapLists.clear();
        csvAsString = csvFileBody.toString();
        csvfileLines = csvAsString.split('\n'); 
        for(string st: csvfileLines[0].split(',')){
          wrap.allCSVFields.add(st);
            wrapLists.add(wrap);  
            //CSVList.add(st);  
        }     
    }
    
    public class wrapperClass{
        public List<string> allCSVFields {get;set;}
        public List<String> APINamesList {get; set;}
    }
I need to read header column of csv file  and those fileds i have to display in vf page.
And those filed i shuld be able to map with the salesforce object . After mapping, insert/update the csv record data into object.
We can get the fields of sobjects by the schema.descrime method. But I am not getting idea to map the csv fields to the sobject fields.
Please someone help me in getting some idea how to get the header columns from the excel and insert into objects
Hi,
I am in part whereI need to get the failed records in a CSV. I am able to get the failed records into a CSV but the records are coming with the fieldNames as I have added the screenshot below.  But I dont want the fields coming with the field Names and object Name.User-added imagePlease Someone help me in getting only the record values

Thanks in Advance
Sachin

Hi all,
I have a task to create a table where i should iterate through 2 lists(dynamic lists). I have used Wrapper class for lists. Below is the code that I have used.
Please someone help me with the code below

*************VisualForce Page**************

<apex:pageBlockSection columns="2"  >
                <apex:pageBlockTable value="{!wrapLists}" var="wrap">
                    <apex:column headerValue="API Names" value= "{!wrap.APINamesList}" />
                    <apex:column headervalue="CSV Fields" value="{!wrap.allCSVFields}" />  
                </apex:pageBlockTable>
            </apex:pageBlockSection> 


*********Controller************

public void getApiNames(){ 	
       wrap = new wrapperClass();
        queryResults = [SELECT API_Names__c,Object__c,Label FROM dataload__mdt WHERE Label= :selectedFunction ];
        allAPINames = queryResults[0].API_Names__c;
        wrap.APINamesList = new List<string>();
        APIList= new List<String>();
        wrapLists.clear();
            for(string APINames: allAPINames.split(',')){
            APINamesMap.put(APINames, APINames);
            system.debug('Test2'+APINames);
            
          wrap.APINamesList.add(APINames);
            System.debug('TEster'+wrap.APINamesList);
              wrapLists.add(wrap);
           // APIList.add(APINames);
        }  
             
    }
    
    Public void saveFile(){
        for(string sac: APIList){
            if(CSVList.contains(sac)){
                insert objDataLoader;
        objAttachment.ParentId = objDataLoader.id;
        insert objAttachment;
            }
        }
        
    }
    
    Public void readcsvFile(){
        CSVList= new List<string>();
        csvFileLines = new List<String>{};
        wrap.allCSVFields= new List<String>();
        wrapLists.clear();
        csvAsString = csvFileBody.toString();
        csvfileLines = csvAsString.split('\n'); 
        for(string st: csvfileLines[0].split(',')){
          wrap.allCSVFields.add(st);
            wrapLists.add(wrap);  
            //CSVList.add(st);  
        }     
    }
    
    public class wrapperClass{
        public List<string> allCSVFields {get;set;}
        public List<String> APINamesList {get; set;}
    }

Hi All,

 

I want to get all fieldnames of a object in apex. How can I do this?

 

For example for User object I want to get all its field names like AboutMe, AccountId , Email etc.

 

Any help on this really appreciated.

 

Regards,

Naren

  • January 18, 2012
  • Like
  • 0