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
RockyDrakeMRockyDrakeM 

Sustituting a custom field dynamically in Apex result of a query

Hello,

I want to query get the values from the already queried result dynamically
I have below snippet
for (QuoteLineItem q : qli){
                String a = 'Designation__c';
                if(String.isNotBlank(q.Designation__c)){  //Work
                            
                }
				if(String.isNotBlank(q.a)){        //Doest not Work
                            
                }
            }
Can anyone tell me, how could i resolve this issue 

thanks for advise
 
Best Answer chosen by RockyDrakeM
venkat-Dvenkat-D
You can use sObject get method for this. 
Refer to https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm 
for more information. 

if(string.isNotBlank(sObj.get(a)))