You need to sign in to do that
Don't have an account?
Dynamic List Item Return Statement
public string getMyAnswer() { list<Administrative_Task__c> QuestionandYearAns = null; QuestionandYearAns = Database.query('select '+ currentQuestion + ' from Administrative_Task__c where plan__c = '+ '\''+SelectedPlanID+'\'' + ' AND year__c =' + '\''+YEQYearValue+'\'');
return QuestionandYearAns[0].Completed_By_Last__c; // return QuestionandYearAns[0].currentQuestion; }
Hi all,
I'm looking for a way to acheive the above (in red). From my query statement, you can see that a variable called currentQuestion is used to specify which Administrative_Task__c field to return, which is chosen by the user on the front end. I would like to be able to return the field dynamically without having to explicity list which field to return (blue).
Any help would be greatly appreciated!
Thanks!
You can use this -
return (String) QuestionandYearAns[0].get(currentQuestion);
All Answers
You can use this -
return (String) QuestionandYearAns[0].get(currentQuestion);