You need to sign in to do that
Don't have an account?
Nejib Ksaier
returnValue is returning empty list
Hi everybody,
I'm trying to get a list in a lightning component. In the sandbox and in the community preview in my org i get a non empty list, but when i use the live version of my community, i get always an empty list for the same settings and same code.
Can someone help?
thanks,
I'm trying to get a list in a lightning component. In the sandbox and in the community preview in my org i get a non empty list, but when i use the live version of my community, i get always an empty list for the same settings and same code.
Can someone help?
thanks,
Thank you for your time and have a nice Day :)
All Answers
Kind regards
getAttachements: function(component) {
var plantId = 'a0F0Y000005c7DcUAI';
var action = component.get('c.getContractAttachedUrl');
action.setParams({
"plantId": plantId
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var urls = response.getReturnValue();
component.set('v.slides', urls);
}
});
$A.enqueueAction(action);
},
and this is my apex class:
@AuraEnabled
public static List<CombinedAttachment> getContractAttachedUrl(String plantId){
// Get Contract Id from plant
Date now = date.today();
Entity_Contract_Relationship__c contractId = [Select Contract__c from Entity_Contract_Relationship__c where Entity__c = :plantId and (Valid_to__c > :now or Valid_to__c =null) limit 1];
// Get Attached Files
List<Contract__c> RepCombinedAttachment = new List<Contract__c>();
List<CombinedAttachment> RepComAttachment = new List<CombinedAttachment>();
RepCombinedAttachment = [Select (Select id, title,contentUrl, LastModifiedDate, createdby.name,RecordType From CombinedAttachments) from Contract__c where id = :contractId.Contract__c];
for(Contract__c cc: RepCombinedAttachment){
if(!cc.CombinedAttachments.isEmpty()) {
for(CombinedAttachment temp : cc.CombinedAttachments){
RepComAttachment.add(temp);
}
}
}
return RepComAttachment;
}
var plantId = 'a0F0Y000005c7DcUAI';
Please don't use the Id directly in code because the id in a Sandbox can be different from Production.
Please tell if this helps you.
Kind regards,
Select Contract__c, Valid_to__c from Entity_Contract_Relationship__c where Entity__c = ' a0F0Y000005c7DcUAI'
Please post a screenshoot
Can you run it in query editor and post the query result?
Do you have any idea what is your list that is coming empty?
Kind regards,
(CombinedAttachment:{ParentId=a0K0Y00000B0U6PUAV, Id=0690Y000004KpABQA0, Title=SGCertifiedPlatformDeveloperI (6), LastModifiedDate=2018-03-12 08:45:46, CreatedById=0050Y000002lzvKQAQ, RecordType=File})
Kind regards,
// Get Contract Id from plant
String plantId = 'a0F0Y000005c7DcUAI';
Date now = date.today();
Entity_Contract_Relationship__c contractId = [Select Contract__c from Entity_Contract_Relationship__c where Entity__c = :plantId and (Valid_to__c > :now or Valid_to__c =null) limit 1];
// Get Attached Files
List<Contract__c> RepCombinedAttachment = new List<Contract__c>();
List<CombinedAttachment> RepComAttachment = new List<CombinedAttachment>();
RepCombinedAttachment = [Select (Select id, title,contentUrl, LastModifiedDate, createdby.name,RecordType From CombinedAttachments) from Contract__c where id = :contractId.Contract__c];
for(Contract__c cc: RepCombinedAttachment){
if(!cc.CombinedAttachments.isEmpty()) {
for(CombinedAttachment temp : cc.CombinedAttachments){
RepComAttachment.add(temp);
}
}
}
System.assertEquals(RepComAttachment.size(), 999999);
What are the relation between CombinedAttachments and Contract__c.
Do you have CombinedAttachments?
Yes i have combined attachement. In this case the Contract__c id is the parentId.
It could be an issue with permissions but i'm not sure which option should i activate in profile for the combinedattachement, because when i run the code as system admin everything looks fine, and when i use the profile i created for the community i get an empty list
So you need to go to profile and give read permissions on the object and fields Contract__c.
KInd regards,
Try access to the record with the id a0F0Y000005c7DcUAI
Thank you for your time and have a nice Day :)