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
stupendous manstupendous man 

Superbadge Advanced Apex challenge 6

Receiving error:

Challenge Not yet complete... here's what's wrong: 
Ensure that you modify the COLLABORATION_GROUP query to use the INVENTORY_ANNOUNCEMENTS constant.

static List<CollaborationGroup> COLLABORATION_GROUP = [SELECT Id FROM CollaborationGroup WHERE 
                                                            Name = : Constants.INVENTORY_ANNOUNCEMENTS OR 
                                                            Name = : 'Test'+Constants.INVENTORY_ANNOUNCEMENTS 
                                                            LIMIT 1];

Tried every variation of the query I could think of (database.query, lowercase class reference, only one 'WHERE' clause, no limit, space after 'Test'...all getting same error). Running the above in anonymous apex works fine and returns expected values. Debugged the class and all uses of the Collaboration_Group to verify it's returning the expected values. The rest of the challenge's functionality is as expected: the announcement is made to the group when criteria is met. Nothing appears to be wrong in the logs created when checking the challenge. One of the logs shows the anonymous apex asserting the results of a very similar query. Is there a best practice I'm missing in referencing the constant inside the query?

Best Answer chosen by stupendous man
Zachery EngmanZachery Engman
Darn sorry that didn't help, as I know how finicky the checks appear to be.  Here is the exact format I have in case it is that finicky.
static List<CollaborationGroup> COLLABORATION_GROUP = [
        SELECT Id
        FROM CollaborationGroup
        WHERE Name =: Constants.INVENTORY_ANNOUNCEMENTS
        OR Name = :('TEST'+Constants.INVENTORY_ANNOUNCEMENTS)
        LIMIT 1
    ];

Maybe also just double-check your constant is defined as such:

public final static string INVENTORY_ANNOUNCEMENTS = 'Inventory Announcements';

All Answers

Zachery EngmanZachery Engman
I passed that challenge, comparing I see my TEST is all caps.  Maybe try that.
stupendous manstupendous man
Thanks Zachery...no luck with that; just tried various types of all caps for TEST and still same error. Tried retyping it in case of copy/paste issues...still there.
Zachery EngmanZachery Engman
Darn sorry that didn't help, as I know how finicky the checks appear to be.  Here is the exact format I have in case it is that finicky.
static List<CollaborationGroup> COLLABORATION_GROUP = [
        SELECT Id
        FROM CollaborationGroup
        WHERE Name =: Constants.INVENTORY_ANNOUNCEMENTS
        OR Name = :('TEST'+Constants.INVENTORY_ANNOUNCEMENTS)
        LIMIT 1
    ];

Maybe also just double-check your constant is defined as such:

public final static string INVENTORY_ANNOUNCEMENTS = 'Inventory Announcements';

This was selected as the best answer
stupendous manstupendous man
Thanks Zachery. I needed the parentheses; the one time I didn't add them in....
Scott Morrison 33Scott Morrison 33
the OR Name = ('TEST' + through me off). I really dislike test specific stuff in none test code.