-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewMyobUtil.cls
30 lines (23 loc) · 1.23 KB
/
newMyobUtil.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class newMyobUtil{
public static Map<String,String> getAllFieldsWithRecordType(String recordTypeId){
// method returns a list of fields based on the Card object record type
Map<Id,RecordType> r = new Map<Id,RecordType>([SELECT Id,Name from RecordType where SObjectType='Card__c']);
List<Schema.FieldSetMember> lf = new List<Schema.FieldSetMember>();
Map<String,String> resultAllFieldsWithRecordType = new Map<String,String>();
lf.addall(SObjectType.Card__c.FieldSets.Personal.getFields());
if (r.get(recordTypeId).Name=='Personal'){
}
else if (r.get(recordTypeId).Name=='Customer'){
lf.addall(SObjectType.Card__c.FieldSets.Card.getFields());
lf.addall(SObjectType.Card__c.FieldSets.Customer.getFields());
}
else if (r.get(recordTypeId).Name=='Supplier') {
lf.addall(SObjectType.Card__c.FieldSets.Card.getFields());
lf.addall(SObjectType.Card__c.FieldSets.Supplier.getFields());
}
for(Schema.FieldSetMember f : lf) {
resultAllFieldsWithRecordType.put(String.ValueOf(f.getFieldPath()),String.ValueOf(f.getType()));
}
return resultAllFieldsWithRecordType;
}
}