function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aa HashAa Hash 

insert failed records in custom object which are failed to import from csv

Hi all,
I have never done apex before,I want to insert failed records in the custom Log__c object which are failed to import from CSV file I have these fields:
Log Name, Field Name__c, error message__c 
In the previous task I imported CSV file into a custom object using the vf page, noe this is its' extended task, If anyone did this before please send me a code.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Can you confirm how many record you have and also are you trying to insert one by one record by giving the details or you want to insert from CSV file?

Thanks,
 
Aa HashAa Hash
1. I have imported all data of CSV file into a custom object CSV__c and mapped all fields.
2. now if any record failed to import its record should be inserted into another Log__c object with error message, field name. 
Now I am stuck on task 2.
Number of records are different in diferent csv files.
Sathish kumar PSathish kumar P
If you are using apex to insert the records Please use try catch to insert records from the other sources. In your case you can use catch block to store the failed record 
Aa HashAa Hash
I am using vs code and I am asking for the complete code, please