1

I am having some trouble inserting a set of values into a custom object (Article_Feedback__c)in my unit test. Does anyone see anything wrong with the way this test was setup? I have tried fixes on similar posts such as rolling back the API version but I cant seem to get it to work.

@isTest(SeeAllData=true)
public class ArticleFlagTest {
   static testMethod void addArticleFeedback(){

        FeedItem f;
        String parentId = 'kA0550000004CNPCA2';

        String q = 'SELECT KnowledgeArticleId, Title FROM KnowledgeArticleVersion WHERE PublishStatus = \'Online\' AND Language = \'en_US\' AND KnowledgeArticleId = \'kA0550000004CNPCA2\' LIMIT 1';


        group g = [SELECT Name,Id FROM Group WHERE Name = 'Knowledge Expert'];

        KnowledgeArticleVersion kav = (KnowledgeArticleVersion) Database.query(q);


        Article_Feedback__c afd = new Article_Feedback__c(
            Article_ID__c = parentId,
            /*Article_Number__c = kav.articleNumber,*/
            Article_Title__c = kav.title,
            Article_Link__c = 'https://login.salesforce.com/'+ kav.KnowledgeArticleId+ '?popup=true',
            Feedback_Status__c = 'Internal',
            OwnerID = g.Id

        );
        insert afd;       
    }

}

1 Answer 1

1

Groups cannot own records (only Users + Queues); Groups are for opening sharing.

This line is referencing a GroupId, not a UserId.

OwnerID = g.Id

Try substituting with your User.Id and see if it inserts or you.

3
  • This does not seem to be the issue. I used the workbench to query the KnowledgeArticleVersion for that Id and it returned the expected article. The issue seems to be when I try to insert the record into Article_Feedback__c.
    – Allen Mann
    Commented Aug 7, 2015 at 16:03
  • @AllenMann, updated answer.
    – James
    Commented Aug 7, 2015 at 20:01
  • 1
    Awesome @James, thanks a lot for the updated answer. This did work for me.
    – Allen Mann
    Commented Aug 10, 2015 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .