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

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.

|improve this answer|||||
  • 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 Aug 7 '15 at 16:03
  • @AllenMann, updated answer. – James Aug 7 '15 at 20:01
  • 1
    Awesome @James, thanks a lot for the updated answer. This did work for me. – Allen Mann Aug 10 '15 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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