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
SfSharkSfShark 

Adding Rows Dynamically to datatable on button click

hai friends,

 

     I have list of contactfields,this list is chanfing dynamically based on user input.Based on the user input i am adding columns dynamically to Datatable,Now i want to add that rows to the datatable dynamically.Here Number of rows also user input.

 

Can you please help me in this scenario.

 

Thank you

Haribabu

Ray DehlerRay Dehler

This can be accomplished pretty simply with a contact trigger, oversimplified example:

 

trigger AddRows on Contact(after insert) {

  List<Record_To_Insert__c> records = new List<Record_To_Insert__c>();

  for (Contact c : Trigger.new) {

    for (Integer i = 0; i < c.Num_Rows_To_Add__c; i++) {

      records.add(new Record_To_Insert__c(Contact__c = c.Id));

    }

  }

  insert records;

}