You need to sign in to do that
Don't have an account?

sObj.getSObject(parentfield) is returning NULL
Hi
I am running this generic code which is used to return set of ID.
public statset<id>getetIdSet(sObject[] pSobjects, string pSObjField){
set<Id> sObjIdSet = new set<Id>();
for(sObject sObj : pSobjects){
if(pSObjField != null){
//split reference fields
string[] refFields = pSObjField.split('\\.');
if(refFields.size() > 1){
System.debug(sObj.getSObject(refFields[0]));
if(sObj.getSObject(refFields[0]) != null && sObj.getSObject(refFields[0]).get(refFields[1]) != null){
sObjIdSet.add(string.valueOf(sObj.getSObject(refFields[0]).get(refFields[1])));
}
}
return sObjIdSet;
}
getIDset(newContacts, 'reference_field__r.field__c');
System.debug( sObj.getSObject(refFields[0])); this statement is returning NULL even though there is value in both the field.
Can someone please help regarding this issue . how to access parent fields when running from child trigger context.
I am running this generic code which is used to return set of ID.
public statset<id>getetIdSet(sObject[] pSobjects, string pSObjField){
set<Id> sObjIdSet = new set<Id>();
for(sObject sObj : pSobjects){
if(pSObjField != null){
//split reference fields
string[] refFields = pSObjField.split('\\.');
if(refFields.size() > 1){
System.debug(sObj.getSObject(refFields[0]));
if(sObj.getSObject(refFields[0]) != null && sObj.getSObject(refFields[0]).get(refFields[1]) != null){
sObjIdSet.add(string.valueOf(sObj.getSObject(refFields[0]).get(refFields[1])));
}
}
return sObjIdSet;
}
getIDset(newContacts, 'reference_field__r.field__c');
System.debug( sObj.getSObject(refFields[0])); this statement is returning NULL even though there is value in both the field.
Can someone please help regarding this issue . how to access parent fields when running from child trigger context.
Check if this is work for you , else please eleborate more about the issue :