You need to sign in to do that
Don't have an account?
davidleckenby
Cannot pull data into a list from a SOQL query referencing a set variable. Hardcoding the value works fine
public class ELOUpload_Class { public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) { //Create a set of all the incoming IDs Set<Id> contDocId = new Set<Id> (); for (ContentDocument contDoc : lstContentDoc ) { contDocId.add(contDoc.Id); } system.debug('contDocId = ' + contDocId ); List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId = '0692O0000003CSTQA2']; system.debug('contDoclink = ' + contDoclink ); } }Hi Guys - I am working with ContentFiles and am trying to get a list to populate with some values from the ContentDocumentLink object. The code above (with hardcoded value) works fine and returns the values. However when trying to do it referencing the set variable (contDocId) in the code below I get no values returned. The contDocId is being pulled correctly too (which is the hardcoded value).
public class ELOUpload_Class { public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) { //Create a set of all the incoming IDs Set<Id> contDocId = new Set<Id> (); for (ContentDocument contDoc : lstContentDoc ) { contDocId.add(contDoc.Id); } system.debug('contDocId = ' + contDocId ); List <ContentDocumentLink> contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId IN :contDocId]; system.debug('contDoclink = ' + contDoclink ); } }Now sure how to proceed? - many thanks for any assistance
Please check whether lstContentDoc is geetting data or not, if not go and check whether the query returns the data or not.
code looks everything is ok.
public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
System.debug('datat===>'+lstContentDoc );
So you should use the after insert.
thanks
so, immediately resource is not available, to use the resources we should use the future method. I hope this one will help you.
public class ELOUpload_Class {
public static void ELOUpload_Method1 (List<ContentDocument> lstContentDoc) {
//Create a set of all the incoming IDs
Set<Id> contDocId = new Set<Id> ();
for (ContentDocument contDoc : lstContentDoc ) {
contDocId.add(contDoc.Id);
}
getDataOf(contDocId);
}
@future
public static void getDataOf(Set<id> contDocId){
List <ContentDocumentLink> contDoclink = new List <ContentDocumentLink> ();
system.debug('contDocId = ' + contDocId );
contDoclink = [SELECT Id, ContentDocumentId FROM ContentDocumentLink WHERE ContentDocumentId IN :contDocId];
system.debug('contDoclink = ' + contDoclink );
}
}