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
Vasavi VajinepalliVasavi Vajinepalli 

Dynamically add/remove rows for sObject types

How to add/remove rows dynamically for sObject types in visualforce page? Please give some working examples.
Shashikant SharmaShashikant Sharma
You could use {!sobject["FieldAPIName"]} to show values in VFP. 

You could look at this example : http://forceschool.blogspot.in/2011/06/dynamic-binding-when-object-name-is.html

Thanks
Shashikant
Vasavi VajinepalliVasavi Vajinepalli
Hi Shashikant,

Am also doing the same in my VF page. But am not able to add a empty row for sObject. Can you please let me know how to add a row with no values for sObject (by not hardcoding the sObject as Account or anything).
Shashikant SharmaShashikant Sharma
No you ahve to have any Id assocaited with SObject. You can not create instance of SObject and use it in VFP. SObject instance has to be populated with any record of any Object.

Thanks
Shashikant
Vasavi VajinepalliVasavi Vajinepalli
Am able to add a row for SObject by using the below code in my controller:

String objectName = 'Some value';
        Schema.SObjectType t  = Schema.getGlobalDescribe().get(objectName);
        SObject sObj = t.newSObject();
        List<sObject> sObjLst1.add(sObj);

Thanks,
Vasavi