+ Start a Discussion
sfdc-apexsfdc-apex 

Loading data from excel using UI?

Hi All,
 
i have a requirement where in i have to load data from excel using UI. is it possible? If yes please do let me know its solution as soon as possible.
 
Thanks in advance,
Bharat
RickyGRickyG
Bharat -

Try looking in the Administrative Setup under Data Management - you will find wizards to import to custom objects and some standard objects.

Hope this helps.  
Cool_DevloperCool_Devloper

But what if the users dont have access to the Setup?

I suppose it wont work in this case. Can we really build a custom UI for allowing the users to acheive this?

 

Cheers,

Cool_D

RickyGRickyG
I guess you could - or you could let them call a command line file that would use Data Loader, if you had EE or UE.
Cool_DevloperCool_Devloper
Thanks Rick for the response.
 
Couple of quick questions on this:
 
1. Is building a custom UI feasible as we have to read the CSV and create records accordingly which might get complex?
2. Running Data Loader from command line essentially means that the users should have Data Laoder setup on their machine.
 
Would be great if you can clarify!!
 
Thanks,
Cool_D
crocodilecrocodile
Hi Ricky,

        I have two custom objects: Admission__c & Student__c

Admission__c has two fields: Admission_Number (Always require a value in this field in order to save a record) & class__c

Student__c has two fields: Admission_Number & Student_Name__c

In both the objects, Admission_Number is the standard field.  Admission_Number is the just Field label of Name Field of both the objects.

For each record created in Admission__c, i want to insert a new record automatically in Student__c and i want to copy the Admission_Number value from Admission__c into Admission_Number of Student__c.



Below are the Trigger and Class codes:

trigger admission_trig1 on Admission__c (before insert)
{
    Admission__c[] admsn1=trigger.new;
    admission_clas1.m1(admsn1);
}



public class admission_clas1 {
    public static void m1(Admission__c[] admsn1 )
    {
        String str=' ';
        for(Admission__c admsn2:admsn1)
        {
            str=(String)admsn2.Name;
        }
       
        Student__c std1=new Student__c(Name=str);
       
        insert std1;
    }
}


ISSUE: Both the class and trigger compiled successfully but when i inserted a record in Admission__c, a new record is not inserted into Student__c.

PLEASE HELP ME IN THIS REGARD.

Thanks in advance,
-Vissu
Cool_DevloperCool_Devloper
Try This:
 
trigger admission_trig1 on Admission__c (before insert)
{
   // Admission__c[] admsn1=trigger.new;
    admission_clas1.m1(trigger.new);
}



public class admission_clas1 {
    public static void m1(Admission__c admsn1 )
    {
        String str=' ';
      //  for(Admission__c admsn2:admsn1)
      //  {
        //    str=admsn2.Name;
      //  }
       
        Student__c std1=new Student__c(Name=admsn1.Name);
       
        insert std1;
    }
}

One more suggestion would be to create the Student record within the trigger itself instead of making a callout to the apex class.
 
Hope this helps!!
Cool_DevloperCool_Devloper

Hi Rick,

 

Would be great if you can give your inputs to the questions i had put across.

 

I need to build a custom UI for giving an option to the users to upload a file, whose rows would be parsed and corresponding records will have to be created as it happens in the Data loader.

 

Can you please advice me how to go about it?

 

Many Thanks,

Cool_D