Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm working on a Visualforce page where I want to grab a user's groups and paginate over the list. Getting the groups is pretty straightforward using the ConnectApi's ChatterUsers.getGroups method (example here). What I'm struggling a bit with is why I am getting the following error when I try to create a class level variable of the return type (ConnectApi.UserGroupPage) to hold the data.

Invalid type: ConnectApi.User​​GroupPage (Line: 3, Column: 26)

I did a little experimenting and noticed if I had either a class level variable or return type for a method of ConnectApi.UserGroupPage, I would receive the Invalid type error. However, if I declared a variable locally inside of a method, it had no problem compiling. Any ideas if this is by design?

public with sharing class GroupsController {

    // This line will error
    @TestVisible private ConnectApi.User​​GroupPage groupsUserIsMemberOf;    

    // If I comment out the class-level variable, this line will error
    public ConnectApi.UserGroupPage getGroupsUserIsMemberOf() {
        // Implementation is meaningless for this error
        return null;
    }
}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

If you use e.g. inspect element in Chrome, you will see that there are a couple of non-rendering Unicode characters between "User" and "GroupPage" in your class level type declaration. Probably picked up cutting and pasting from some documentation.

Key "UserGroupPage" in from scratch and that declaration will compile as you expect.

PS The characters are "ZERO WIDTH SPACE" which are "intended for invisible word separation and for line break control".

share|improve this answer
    
Wow, I can't believe you caught that. Thanks! –  Michael Welburn Aug 14 at 22:31

Not sure if this is by design. Can you return a the same type in a wrapper class and see if that works ?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.