• Philip Bolognini
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

I have a test method which tests a number of Knowledgebase related objects. In my Apex Class, I have the following code:

 

 

        String queryvar = 'FIND \'' + '*' + searchQ + '*' + '\'' + ' IN ALL FIELDS Returning ' + 'Knowledgebase__kav(Id, Title, Summary, UrlName WHERE PublishStatus =\'Online\')';
        List<List<SObject>> searchList = search.query(queryvar);
        Knowledgebase__kav [] documents = ((List<Knowledgebase__kav>)searchList[0]);
        if (!documents.isEmpty()) {
            for (Knowledgebase__kav c : documents) {
                // Do stuff...
            }   
        }  else {
            // Do different stuff...
        }

In my test method I then create a new Knowlegebase__kav object but when trying to set PublishStatus = 'Online', I'm told the field is not writeable. I need to mark it as 'Online' as that's what my Apex Class is looking for.

 

 

Any great ideas?

 

Cheers.

 

/Søren Nødskov Hansen