I guess this code should work for multiple contacts importing from csv., right, Correct me if am Wrong some where ?? I have got neither error nor debug log error. Successed but couldn't trace out whats fone wrong.
In your PP_Map Key is program name but in for loop you are try to get map value from contact Email . Is program name is email id ? if no then very time you will get null only
Thanks for your prompt replies, Am trying to insert data from .CSV file, to insert contact, member with program name, but i am get null for program id, while inserting member.
Also this is inserting only for one row. Please let me know how to insert multiple rows in the csv. to insert contacts, members with programid.
In the code that you posted here will work for multiple records. since you are looping the csvFileLines. Code looks good and it has to work. use CP_Map.put(conObj,Email.trim(),csvRecordData[4].trim()); instead of CP_Map.put(conObj,Email,csvRecordData[4]);
I guess this code should work for multiple contacts importing from csv., right, Correct me if am Wrong some where ?? I have got neither error nor debug log error. Successed but couldn't trace out whats fone wrong.
I guess this code should work for multiple contacts importing from csv., right, Correct me if am Wrong some where ??
I have got neither error nor debug log error. Successed but couldn't trace out whats fone wrong.
Code:
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Contact conObj = new Contact() ;
string[] csvRecordData = csvFileLines[i].split(',');
conObj.FirstName= csvRecordData[0];
conObj.LastName= csvRecordData[1];
conObj.Email= csvRecordData[2];
conObj.Phone= csvRecordData[3];
conlist.add(conObj);
CP_Map.put(conObj.Email.trim(),csvRecordData[4].trim());
system.debug('@@@@@@@@@@@@@@@@@@@'+ CP_Map);
}
Debug log : When inserting multiple contacts from csv and the error msg.
All Answers
I could n't see any issues in the code. if possible can you use trim() when adding to map.
In your PP_Map Key is program name but in for loop you are try to get map value from contact Email .
Is program name is email id ? if no then very time you will get null only
Thanks for your prompt replies, Am trying to insert data from .CSV file, to insert contact, member with program name, but i am get null for program id, while inserting member.
Also this is inserting only for one row. Please let me know how to insert multiple rows in the csv. to insert contacts, members with programid.
Thanks in Advance,
Bhu'1
In the code that you posted here will work for multiple records. since you are looping the csvFileLines. Code looks good and it has to work. use CP_Map.put(conObj,Email.trim(),csvRecordData[4].trim()); instead of CP_Map.put(conObj,Email,csvRecordData[4]);
Please let me know, how to process bulk data..... from csv, Its throwing some error.
Thanks in Advance....
Try to follow the eg. mentioned in the link below. I am doing this reading the csv file from documents and loading data to objects.
http://sfdcintegration.blogspot.in/2016/07/read-csv-file-from-documents-and-create.html
can you please post the error what you are getting. so that i can get what exactly the issue you are facing.
I guess this code should work for multiple contacts importing from csv., right, Correct me if am Wrong some where ??
I have got neither error nor debug log error. Successed but couldn't trace out whats fone wrong.
Code:
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
for(Integer i=1;i<csvFileLines.size();i++){
Contact conObj = new Contact() ;
string[] csvRecordData = csvFileLines[i].split(',');
conObj.FirstName= csvRecordData[0];
conObj.LastName= csvRecordData[1];
conObj.Email= csvRecordData[2];
conObj.Phone= csvRecordData[3];
conlist.add(conObj);
CP_Map.put(conObj.Email.trim(),csvRecordData[4].trim());
system.debug('@@@@@@@@@@@@@@@@@@@'+ CP_Map);
}
Debug log : When inserting multiple contacts from csv and the error msg.
public void importCSVFile(){
try{
csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
System.debug('Total Lines:'+csvFileLines.size());
for(Integer i=0;i<csvFileLines.size();i++){
System.debug('Line No:'+csvFileLines[i]);
Contact conObj = new Contact() ;
string[] csvRecordData = csvFileLines[i].split(',');
conObj.FirstName= csvRecordData[0];
conObj.LastName= csvRecordData[1];
conObj.Email= csvRecordData[2];
conObj.Phone= csvRecordData[3];
conlist.add(conObj);
CP_Map.put(conObj.Email.trim(),csvRecordData[4].trim());
system.debug('@@@@@@@@@@@@@@@@@@@'+ CP_Map);
}
try this in the debug you can see all the lines in the debug.