• Aa Hash
  • NEWBIE
  • 10 Points
  • Member since 2022
  • Salesforce

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
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.
  • September 15, 2022
  • Like
  • 0
Hi all
It's really urgent I am totally new to coding I want to import my excel file to my custom object Sample__c to create new records using visual force page but even after searching, I am unable to complete it and am totally stuck.
I have an excel file with columns Name, Email, Phone and need to import the values to Sample__c fields Name__c, Email__c, Phone__c but can't do this any help from experts as I already followed all the links related to this now I need full code.
Thanks
I have created an apex code which is populating account lookup on custom object but I want my trigger only fires when field value EXT ID__c in the custom object is changed it also create an error message on another log__c object when duplication occurs
Here is my code: 
trigger Test_Account on Populate_Account__c (before insert, before update) {
    set<string> externalids = new set<string>();
for(Populate_Account__c cobj:trigger.new){
if(cobj.External_ID__c != Null && cobj.Account__c==Null ){
externalids.add(cobj.External_ID__c);
}
}
Map<string,id> mapaccidswithexternalids = new Map<string,id>();
for(Account acc: [select id,External_ID__c from account where External_ID__c=:externalids]){
mapaccidswithexternalids.put(acc.External_ID__c,acc.id);
}
for(Populate_Account__c cobj:trigger.new){
if(mapaccidswithexternalids.containskey(cobj.External_ID__c)){
cobj.Account__c = mapaccidswithexternalids.get(cobj.External_ID__c);
}
}
}
 
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.
  • September 15, 2022
  • Like
  • 0
Hi all
It's really urgent I am totally new to coding I want to import my excel file to my custom object Sample__c to create new records using visual force page but even after searching, I am unable to complete it and am totally stuck.
I have an excel file with columns Name, Email, Phone and need to import the values to Sample__c fields Name__c, Email__c, Phone__c but can't do this any help from experts as I already followed all the links related to this now I need full code.
Thanks
I have created an apex code which is populating account lookup on custom object but I want my trigger only fires when field value EXT ID__c in the custom object is changed it also create an error message on another log__c object when duplication occurs
Here is my code: 
trigger Test_Account on Populate_Account__c (before insert, before update) {
    set<string> externalids = new set<string>();
for(Populate_Account__c cobj:trigger.new){
if(cobj.External_ID__c != Null && cobj.Account__c==Null ){
externalids.add(cobj.External_ID__c);
}
}
Map<string,id> mapaccidswithexternalids = new Map<string,id>();
for(Account acc: [select id,External_ID__c from account where External_ID__c=:externalids]){
mapaccidswithexternalids.put(acc.External_ID__c,acc.id);
}
for(Populate_Account__c cobj:trigger.new){
if(mapaccidswithexternalids.containskey(cobj.External_ID__c)){
cobj.Account__c = mapaccidswithexternalids.get(cobj.External_ID__c);
}
}
}