0

i want to fetch the record name using record id. below is my dynamic query

SObject record = Database.query('Select CaseNumber From ' + sObjName + ' Where Id = :subOrderId');

Could anyone please let me know how can i extract the CaseNumber alone from the above query.

  • 1
    SObject's have getter methods with which you can return fields. record.get('CaseNumber') doesn't work? – Raul Feb 23 '18 at 10:33
  • tried without quotes record.get(CaseNumber) so i was getting some errors. Now, its resolved, Thank you so much for your response. – Sab__Dev Feb 23 '18 at 10:38
1

For accessing fields from SObject use getter methods like:

// with String
record.get('CaseNumber')

or

// with Schema.sObjectField
record.get(Schema.Case.CaseNumber)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.