You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Update answer to add categories

Received Response
16
Views
3
Comments
edited May 26, 2018 4:43PM in Knowledge Management 3 comments

Content

Hi guys!

I'm trying to update an answer to associate new categories to it through a PHP API but with no sucess. When I run the API no changes to the list of categories are made. If I try, however, to change the category (the else statement of the code below) it works fine.

My code is like this:

$answer = RNCPHP\Answer::fetch(a_id);    
if($answer->Categories){
    $answer->Categories[0] = RNCPHP\ServiceCategory::fetch(cat_id);
}
else{
  $answer->Categories = new RNCPHP\ServiceCategoryArray();
   $answer->Categories[0] = RNCPHP\ServiceCategory::fetch(cat_id);
}   

Does anyone know where I'm getting it wrong?

Thanks!!

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!