You need to sign in to do that
Don't have an account?
Not able to create Idea object in test class
I am trying to create an Idea object in test class as a customer portal user. but getting following error:
System.DmlException: Insert failed. First exception on row 0; first error: COMMUNITY_NOT_ACCESSIBLE, You do not have permission to access the community that this entity belongs to. You must be given permission to the community before you can access this entity.: [CommunityId]
I am using following apex code in test class:
List<Community> listCommunity = [Select c.Name, c.IsActive, c.Id From Community c where IsActive=true and name=:TestClassUtility.PORTAL_COMMUNITY_NAME limit 1];
System.runAs(portaluser){
Idea myIdea = new Idea(CommunityId = listCommunity.get(0).Id);
myIdea.title = ' Test Idea';
myIdea.body = ' test idea';
insert myIdea;
IdeaComment iComm = new IdeaComment(IdeaId = myIdea.Id);
iComm.CommentBody = ' I like this idea';
insert iComm;
}
Thanks in advance for any help.
Hi,
I have the same problem, I have setup a customer portal and a community which is shown in the customer portal.
I have then created a custom portal user and after adding the idea tab I have successfully created an idea via the standard interface.
Moreover, I have created a simple visualforce page and controller:
Please note i have hardcoded the ids, just for testing.
After, adding the page to the customer portal profile and accessing the portal as the portal user, I could post an idea, clicking on the link.
It looks like the test method does not allow what is otherwise possible, both with the standard UI and with visualforce/apex.
My two cents: I would log a case from your org and give access to salesforce support.
Thanks for the reply.
Is there any solution available for this. I tried to check the Field level security of Idea fields, surprisingly the field "CommunityId" is not available there in the list of Idea fields.
Thanks in Advance!