I am going through an strange issue while implementing a validation rule/trigger. i want to check if article are in approved status (custom field) before it can be publish. i don't want to allow a user to publish an article which are not approved.

i tried this using validation rule on Knowledge__kav but this validation rule does not fire with the below rule criteria.

IF(AND( RecordType.DeveloperName == "Solution_Article", 
  ISPICKVAL(PublishStatus, "Online")) , true, false)

So, when article are publish, their PublishStatus is changed to 'Online', hence i tried to catch this in a trigger (below) but i am not able to catch the status change, as the PublishStatus is always in draft.

trigger KnowledgeTrigger on Knowledge__kav (before update) {

    if(Trigger.isUpdate && Trigger.isBefore){

        Set<ID> setKnwId = new Set<ID>();

        Id devRecordTypeId = Schema.SObjectType.Knowledge__kav.getRecordTypeInfosByName().get('Solution Article').getRecordTypeId();

        for(Knowledge__kav k1: trigger.old){
            system.debug('k old ' + k1);

        for(Knowledge__kav k: trigger.new)          
            system.debug('k ' + k);

            if(k.Id != null && k.PublishStatus == 'Online' && k.RecordTypeId == devRecordTypeId)


Can you please help me out in this?

  • 1
    How can a developer name can have space... please recheck it.. RecordType.DeveloperName == "Solution Article"
    – Ayub
    Commented Nov 21, 2018 at 6:06
  • @ayub hi.. it was by mistake, have edited it now. it doesn't work.. btw i have mentioned my trigger as well.. you should have considered that.. rather then marking this question as -ve. the problem statement here is i am not able to catch the publisStatus when it changes to 'Online' from 'Draft'.. Commented Nov 21, 2018 at 6:16
  • Publishstatus change can not be tracked in process builder and trigger ...you may need to find out any other workaround ...and your question looks reasonable ...I did not downvote it.
    – Ayub
    Commented Nov 21, 2018 at 6:20
  • @ayub sorry about that. I can't find any workaround for this. if you could help me out in this, i would be thankful. Commented Nov 21, 2018 at 6:23
  • I do have a workaround....let me add as answer ...
    – Ayub
    Commented Nov 21, 2018 at 6:30

1 Answer 1


Knowledge Article object is very special object - you can not track changes of PublishStatus field in trigger/process builder. As workaround (not very good solution) -

  1. Remove "Publish" button from layout.

  2. Add a button using formula field. You can make this button prominent using any image. Place at very top-right in layout.

  3. This Formula field would redirect to a visualforce page with record id as parameter.

  4. On this page show error message if approval status is not approved.

  5. If approval status is approved then publish the record using PublishingService Class: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_knowledge_kbManagement.htm

    String articleId = 'Insert article ID';
    KbManagement.PublishingService.publishArticle(articleId, true);

  • Thank you for pioneering, wrote a lightning component and used this class to get the requirement. Commented Nov 22, 2018 at 9:16
  • Glad it helped!
    – Ayub
    Commented Nov 22, 2018 at 9:41

You must log in to answer this question.

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