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
Akshay MhetreAkshay Mhetre 

How to make fields Null which are retrieving from Field Set.

Hello   I am retrieving fields from FieldSet with Values. I am trying to make those fields null but no luck..  Help me to make fields Null.( getFieldPath() )    
for(SObject s:obj){ if(s.getFieldPath()!= Id){ s.getFieldPath() =null; lstobj.add(s); } }

public static Boolean getMerchandise(List<Schema.FieldSetMember> lstFields, String objectName, String oppID) {
Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe();
Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
system.debug('DescribeSObjectResultObj'+DescribeSObjectResultObj.getName());
String queryString = 'SELECT Id';

for(Schema.FieldSetMember f : lstFields) {
queryString +=', ' +f.getFieldPath() ;
}
queryString += ' FROM '+DescribeSObjectResultObj.getName();
queryString += ' WHERE Loan_Application__c=\'' +oppId + '\'';
system.debug('queryString==>'+queryString);
SObject obj= Database.query(queryString);
system.debug('obj==>'+obj);

for(SObject s:obj){
if(s.getFieldPath()!= Id){
s.getFieldPath() =null;
lstobj.add(s);
}
}
upsert lstobj;
return true;
}
 

 

 

Adarsh CrestAdarsh Crest
Adarsh Crest https://www.adarshcrest.co/ is very premium apartment coming up in Kempapura,Hebbal,North Bangalore https://www.adarshcrest.co/location/