I have created one wrapper class with sObject and index for sObject and im getting and setting list of wrapper to show on VF page.
On VF page im showing some fields from that sObject and provided one button to clone that record so that it will be shown on next row.
At the controller if i assign values directly from wrapper (i.e. new wrapper instance = wrapper instance to be clone) its getting cloned and displayed on VF but while saving its giving me error as "id" of sObject is also get clonned.
If i try to get field values one by one from wrapper its giving me null values.
(eg new wrapper.sObject.field = wrapperToBeCloned.sObject.field), sObject from the wrapper to be cloned is giving null values.
How to solve this problem ?
Best Answer
I think you need to clone an sObject first, and then add it to a new instane of the wrapper. I've created a simple example page and controlle where the wrapper records could be cloned:
Page:
Controller:
The result page: