now i get custom field which has lookup. now i want to write trigger on smagicinteract__Incoming_SMS__c which filed has lookup i have to create one task
Let me see if I can figure out what you're looking for:
1. Dynamically get all fields on an object that are Lookup fields 2. Find every record in your trigger that has a Lookup field populated 3. Create a task for that record with the Lookup field name/values
Is this correct? If so you're almost there =) David
P.S. you can create tasks using workflows, which might save you some time instead of coding!
DescribeSObjectResult objDef = objToken.getDescribe();
Schema.DisplayType fieldType ;
Map<String, SObjectField> fields = objDef.fields.getMap();
for(String s:fields.keySet()){
Schema.DescribeFieldResult f=fields.get(s).getDescribe();
fieldType = f.getType();
if(fieldType == Schema.DisplayType.REFERENCE){
if(f.isCustom()){
System.debug(s);
}
}
}
now i get custom field which has lookup. now i want to write trigger on smagicinteract__Incoming_SMS__c which filed has lookup i have to create one task
for(smagicinteract__Incoming_SMS__c sms : Trigger.new){
ilist.add(sms);
// incomingidmap.put(sms,); here i require lookup field id dynamically
System.debug('=----'+incomingidmap);
}
thanks in advance
1. Dynamically get all fields on an object that are Lookup fields
2. Find every record in your trigger that has a Lookup field populated
3. Create a task for that record with the Lookup field name/values
Is this correct? If so you're almost there =)
David