function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KevinRussellKevinRussell 

Error: sObject type 'Affiliations' is not supported.

I'm trying to query against a map of local records I populated and getting the error:

Error: sObject type 'Affiliations' is not supported.

 

 // Contact Affiliation count
RecordCount = [select count() from Affiliations where npe5__Contact__c = :record.npe5__Contact__c ];

 

What might I be doing incorrectly?

 

Thanks,

 

Kevin

 

Partial code listing:

 // Create trigger for new or selected npe5__Affiliation__c  record
       for(npe5__Affiliation__c  record:trigger.new)        
       {
        
        // Store temporary Affiliation records
        map< id, npe5__Affiliation__c > Affiliations = new map< id, npe5__Affiliation__c >();
     
        // Building local list
        for (npe5__Affiliation__c afl : [Select Id, npe5__Contact__c, npe5__Organization__c, Type__c, npe5__Status__c, npe5__Role__c from npe5__Affiliation__c  
            WHERE npe5__Contact__c = :record.npe5__Contact__c AND npe5__Organization__c = :record.npe5__Organization__c ] ){
            Affiliations.put(afl.id, afl);
        }
      

           // Contact Affiliation Speaker count
           RecordCount = [select count() from Affiliations where npe5__Contact__c = :record.npe5__Contact__c ]; 

        

 

Avidev9Avidev9
Seems like a API name mismatch!
From your code is seems like the API name is "npe5__Affiliation__c"

So the query should be

RecordCount = [select count() from npe5__Affiliation__c where npe5__Contact__c = :record.npe5__Contact__c ];
souvik9086souvik9086

Yes, give like this

 

RecordCount = [select count() from npe5__Affiliation__c where npe5__Contact__c = :record.npe5__Contact__c ]; 

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

KevinRussellKevinRussell

Thanks souvik9086,

 

But, I'm trying to querry my local Affiliations list I built so I think I want to query Affiliations, unless I'm mixing up how I reference the local map.

 

Can I query the Affiliations map directly?

 

// Store temporary Affiliation records
 map< id, npe5__Affiliation__c > Affiliations = new map< id, npe5__Affiliation__c >();
     
// Building local list
 for (npe5__Affiliation__c afl : [Select Id, npe5__Contact__c, npe5__Organization__c, Type__c, npe5__Status__c, npe5__Role__c from npe5__Affiliation__c  WHERE npe5__Contact__c = :record.npe5__Contact__c AND npe5__Organization__c = :record.npe5__Organization__c ] )

{
            Affiliations.put(afl.id, afl);
 }

 

souvik9086souvik9086

Then try something like this and let me know what happens

 

RecordCount = [select count() from npe5__Affiliation__c where id in :Affiliations.keyset() and npe5__Contact__c = :record.npe5__Contact__c ];

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

KevinRussellKevinRussell
Doesn't like it. But having said that, if it did, it looks like it would be making query calls on the npe5__Affiliation__c object. I'm trying to keep all calls on the local Affiliations list I populated because I'm going over my query limit, on the entire trigger in an external data uploading job.

Seems like this should be so much simpler that it is......

Thanks!!!

Error: Method does not exist or incorrect signature: [LIST<npe5__Affiliation__c>].keyset() at line 44 column 90