I want to update data category selection from knowledge article's custom field.

enter image description here I have written a process builder and calling apex from there. but it is not updating data category selection But in debug logs i can see insertion is done. Below is the apex class:

    public static void updatekMA1rticleType(List<Id> knowledgeid)

        List<Knowledge__DataCategorySelection> kADCSLst = new List<Knowledge__DataCategorySelection>();
        List<Knowledge__kav> kArticle = [SELECT ID FROM Knowledge__kav  WHERE Id IN: knowledgeid];
       for(Knowledge__kav kak: kArticle)
            Knowledge__DataCategorySelection kADCS = new Knowledge__DataCategorySelection();
            kADCS.ParentId = kak.Id;
            kADCS.DataCategoryGroupName = 'Geography';
            kADCS.DataCategoryName = 'India';



Can anyone help me?

| improve this question | | | | |
  • @santanuBoral Can you help me on this? – SFDC Jul 9 '18 at 7:24
  • If I run the code from Developer Console, it is perfectly inserting data category into my one of the published article – Santanu Boral Jul 9 '18 at 9:34
  • @Santanu Boral: Thanks for reply..it is working fine for me too but when same code is called from process builder then it is not working.. I checked the logs it is inserting data but i think it is getting rolled back..I have written process builder on Knowledge object(__kav).. – SFDC Jul 9 '18 at 9:36
  • Is that correct version Id is getting passed to that method? can you post process picture? – Santanu Boral Jul 9 '18 at 9:40
  • @Santanu Boral: I added the picture of process builder. I am passing the [knowledge__kav.id] to the method. In debug logsi can see data categories selection is getting inserted but it is getting rolled back for some reason. – SFDC Jul 9 '18 at 10:21

I got the solution. I used @future annotation method called from @invocableMethod then it was working fine.

| improve this answer | | | | |
  • @ SFDC Can you please share where the @Future should be used from the abouve code? – Samuel Robert Apr 20 at 9:03

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.