You need to sign in to do that
Don't have an account?
Looping over fields from a SOQL result
I'm attempting to write a generic field check that our users can easily update for merging with conga docs.
I have a custom object that maps fields that are required for the docs to properly complete. I then create a sql query from those results and run it against the appropriate oject:
Map<id,Merge_Fields__c> reqFields = new Map<id,Merge_Fields__c>([select ID,field_name__c,object_name__c from Merge_Fields__c where Object_Name__c = 'Property']); for (Conga_Merge_Fields__c field : reqFields.values() ) { query = query+field.Field_Name__c; } query = query+' from Property__c where id = \''+currentOpportunity.Property__c+'\'';
Property__c prop = Database.query(query);
I then query the DB with the query string and get the fields/values that are required.
I'm stuck on how i can loop over each returned field to check if it's null/blank/0. Is there any way to do this? I need to know which field failed to properly direct the users on what needs to be fixed.
you can do this in one step: