You need to sign in to do that
Don't have an account?
Monishan M
Salesforce relationship query not fetching result
Hi,
I have written below trigger. But I am not getting any value in the query list. The issue occurs when I give Account_vod__r.country_code_az__c IN :CountryCodes. Can you please let me know why this occurs?
trigger UpdateTA on Survey_Target_vod__c (after update) {
Management_Setting__c AZMEE =Management_Setting__c.getOrgDefaults();
List<String>Countrycodes = new List<String>();
If(AZMEE.Spkr_Therapy_Areas__c!=null){
List<String>Countrycodes = AZMEE.Spkr_Therapy_Areas__c.split(';');
system.debug('hello' +Countrycodes);
}
List<Survey_Target_vod__c> relatedsurveytarget = [SELECT Id,Therapy_Area__c,Submitted_DateTime_vod__c,Name,Account_vod__c,Survey_vod__r.Product_vod__c,Segment_vod__c,
Survey_vod__c,LastModifiedDate,Survey_vod__r.Detail_Group_vod__c,
Survey_vod__r.Product_Metric_AZ__c,Survey_vod__r.Product_Metric_AZ__R.Field_Name_AZ__c FROM Survey_Target_vod__c
WHERE id IN :Trigger.New and Status_vod__c ='Submitted_vod'
and Survey_vod__r.Profiling_Survey_AZ_RU__c=True and Survey_vod__r.Profiling_Type_AZ__c='Question Score Based'
and Account_vod__r.Country_Code_AZ__c IN :Countrycodes
];
system.debug('countrylist' +relatedsurveytarget);
The List relatedsurveytarget is empty when checked in debug logs. But i have a record which satisfies all the above condition but still not getting fetched in this query.
Thanks
I have written below trigger. But I am not getting any value in the query list. The issue occurs when I give Account_vod__r.country_code_az__c IN :CountryCodes. Can you please let me know why this occurs?
trigger UpdateTA on Survey_Target_vod__c (after update) {
Management_Setting__c AZMEE =Management_Setting__c.getOrgDefaults();
List<String>Countrycodes = new List<String>();
If(AZMEE.Spkr_Therapy_Areas__c!=null){
List<String>Countrycodes = AZMEE.Spkr_Therapy_Areas__c.split(';');
system.debug('hello' +Countrycodes);
}
List<Survey_Target_vod__c> relatedsurveytarget = [SELECT Id,Therapy_Area__c,Submitted_DateTime_vod__c,Name,Account_vod__c,Survey_vod__r.Product_vod__c,Segment_vod__c,
Survey_vod__c,LastModifiedDate,Survey_vod__r.Detail_Group_vod__c,
Survey_vod__r.Product_Metric_AZ__c,Survey_vod__r.Product_Metric_AZ__R.Field_Name_AZ__c FROM Survey_Target_vod__c
WHERE id IN :Trigger.New and Status_vod__c ='Submitted_vod'
and Survey_vod__r.Profiling_Survey_AZ_RU__c=True and Survey_vod__r.Profiling_Type_AZ__c='Question Score Based'
and Account_vod__r.Country_Code_AZ__c IN :Countrycodes
];
system.debug('countrylist' +relatedsurveytarget);
The List relatedsurveytarget is empty when checked in debug logs. But i have a record which satisfies all the above condition but still not getting fetched in this query.
Thanks
Can you try using a hardcoded value instead of a bind variable (:CountryCodes). Please use the country_code_az__c value from the record
Please let me know if your query fetches the result that way