1

I have piece of code below:

for(Schema.FieldSetMember fsm : SObjectType.Vacancy_D2D__c.FieldSets.Tooltip_fields.getFields()){
   if(fsm.getType() == 'String'){
       tool += Utility.addTableRow(fsm.getLabel(), String.valueOf(d.get(fsm.getFieldPath())));
   }}

I just want to check what kind of data it has returned abd based on that I'll proceed. But I'm getting error as below.

Comparison arguments must be compatible types: Schema.DisplayType, String

2

fsm.getType() return Schema.DisplayType value so to compare it with string data type you need to convert it into string.

for(Schema.FieldSetMember fsm : SObjectType.Vacancy_D2D__c.FieldSets.Tooltip_fields.getFields()){
   if(String.valueOf(fsm.getType()) == 'String'){
       tool += Utility.addTableRow(fsm.getLabel(), String.valueOf(d.get(fsm.getFieldPath())));
   }}

or you can also use Schema.DisplayType.String

if(fsm.getType() == Schema.DisplayType.String){
           tool += Utility.addTableRow(fsm.getLabel(), String.valueOf(d.get(fsm.getFieldPath())));
       }}

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.