3

I am using salesforce standard set controller and displaying 4 records a page,

I have input fields where i entering values and i wanted to save records on save button clicked.

I want to create a child record for each record.i.e i want update the four field instead the complete list,can i know to get the id's of the four records.

can know how can records values page wise.

1
  • user6833, it's not entirely clear what you're trying to ask. Maybe adding more detail or including your code will help us help you. Commented Mar 21, 2014 at 14:13

1 Answer 1

5

Yes, you can get the ids of the records. In the constructor for your standardset extension, you can get the records using the following code:

public List<sObject> myRecords {get; private set;}

public MyClass(ApexPages.StandardSetController ctrl){
    myRecords = ctrl.getRecords();
    // - OR -
    myRecords = ctrl.getSelectedRecords();

    //To get the ids of those records, you could do something similar to:
    Set<Id> myRecordIds = (new Map<Id,sObject>(ctrl.getRecords())).keySet();
}

From there you can either make updates to myRecords, or use their Ids to generate children records based on those parents. Note, the getSelectedRecords is relevant if for instance you have a related list with checkboxes and a custom button (meaning the getSelectedRecords method will give you the records in that related list that are checked).

Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .