I am using Schema.SobjectField to get all the fields of Account object.
I am getting correct result in my development org. But when i add the class in a package and install it in another sf org, i am not getting correct fields result.
Let me explain where i getting wrong result:
Ex:My package abc contain a custom field (let say xyz_c for account object). My subscribing org also containing the same field (xyz_c) but both are differ with respect to namespace prefix as package field Api name becomes abc_xyz_c after installation. When my code is executed like this:
//....................Some code......................
List<String,String> fieldList = new List<String,String>();
Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();
Map <String, Schema.SObjectField> fieldMap = gd.get('Account').getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values()){
schema.describefieldresult dfield = sfield.getDescribe();
String name = dfield.getname();
String label =dfield.getLabel();
fieldList.add(name,label);
}
//.....................Some code.....................
The resultant fieldList showing all the fields including abc_xyz_c except xyz_c (which is the subscribing org existing field).
Can anybody help me why it is working like this and how can i resolve this issue?