You need to sign in to do that
Don't have an account?
Wilmer
how to validate a field type in Apexcode?
Hi, I´d like to know if there´s a way to check by using ApexCode the field type. i.e: we want to know if the requested field value in a dynamic query is a number, string, boolean, date, datetime, etc.
Select field1__c from MyCustomObject__c
so in this example, I'd like to know what field type is field1__c.
or, lets suppose we got different kinds of values into a string field (only for customization convenience) and then, I query that field and want to establish if that value is a number, date, datetime, etc only by using ApexCode. I didn´t find any IsNumber or IsBoolean methods in Apex documentation.
Thanks,
Wilmer
Select field1__c from MyCustomObject__c
so in this example, I'd like to know what field type is field1__c.
or, lets suppose we got different kinds of values into a string field (only for customization convenience) and then, I query that field and want to establish if that value is a number, date, datetime, etc only by using ApexCode. I didn´t find any IsNumber or IsBoolean methods in Apex documentation.
Thanks,
Wilmer
Hey try this..
After a long research i found this and is working perfect
Look at Dynamic APEX in the manual
Map<String, Schema.sObjectField> M = Schema.SObjectType.Account.fields.getMap();
schema.DescribeFieldResult F = m.get(Field API Name).getDescribe();
String fieldtype = F.getType().name();
All Answers
Hey try this..
After a long research i found this and is working perfect
Look at Dynamic APEX in the manual
Map<String, Schema.sObjectField> M = Schema.SObjectType.Account.fields.getMap();
schema.DescribeFieldResult F = m.get(Field API Name).getDescribe();
String fieldtype = F.getType().name();