You need to sign in to do that
Don't have an account?

Trigger not called by Workflow/process
Hello,
i have an issue with appoval process on Knowledge Articles. It runs through the approval process but it is not calling the trigger when ValidationStatus is 'Validated' and PublishStatus is 'Online' as it should.
trigger:
As i understand the log, the trigger is not called when the article passed the approval process and is published.
How can i solve this issue?
thanks
Peter
i have an issue with appoval process on Knowledge Articles. It runs through the approval process but it is not calling the trigger when ValidationStatus is 'Validated' and PublishStatus is 'Online' as it should.
public testMethod static void testKartKnowledge(){ Knowledge__kav art = new Knowledge__kav(); art.Title = 'Test'; art.Summary = 'Test Summary'; art.RecordTypeId = Schema.SObjectType.Knowledge__kav.getRecordTypeInfosByName().get('Kart').getRecordTypeId(); art.IsVisibleInCsp = true; art.IsVisibleInPkb = true; art.IsVisibleInPrm = true; art.UrlName = 'ttttttttttttttt'; art.Article_Body__c = 'wergwgwegq rfewrg aerg ear ge r'; insert art; Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest(); req.setComments('Submitted for Approval. Please Review'); req.setNextApproverIds(new Id[] {UserInfo.getUserId()}); req.setObjectId(art.Id); req.setSkipEntryCriteria(true); req.setProcessDefinitionNameOrId('Approval_of_Knowledge_Articles_new'); //Knowledge__kav art4 = [Select Id, PublishStatus, KnowledgeArticleId, Language, ValidationStatus, RecordType.DeveloperName FROM Knowledge__kav WHERE Id = :art3.Id]; Approval.ProcessResult result = Approval.process(req); System.debug(result); System.assert(result.isSuccess()); List<Id> newWorkItemIds = result.getNewWorkitemIds(); // Instantiate the new ProcessWorkitemRequest object and populate it Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest(); req2.setComments('Approving request.'); req2.setAction('Approve'); req2.setNextApproverIds(new Id[] {UserInfo.getUserId()}); // Use the ID from the newly created item to specify the item to be worked req2.setWorkitemId(newWorkItemIds.get(0)); // Submit the request for approval Approval.ProcessResult result2 = Approval.process(req2); // Verify the results System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess()); System.assertEquals( 'Approved', result2.getInstanceStatus(), 'Instance Status'+result2.getInstanceStatus()); Knowledge__kav art4 = [Select Id, PublishStatus, KnowledgeArticleId, Language, ValidationStatus, RecordType.DeveloperName FROM Knowledge__kav WHERE Id = :art.Id]; System.debug('ART 4 :: ' + art4); //KbManagement.PublishingService.publishArticle(art4.KnowledgeArticleId, true); }
trigger:
trigger TrgKnowledgeSendNotification on Knowledge__kav (after update) { System.debug('TRIGGER :: ' + Trigger.New); id kartId = Schema.SObjectType.Knowledge__kav.getRecordTypeInfosByName().get('Kart').getRecordTypeId(); if(Trigger.Old != null){ if(Trigger.New[0].ValidationStatus == 'Validated' && Trigger.New[0].RecordTypeId == kartId && Trigger.New[0].PublishStatus == 'Online'){ KnowledgebaseMailTriggerHandler kmth = new KnowledgebaseMailTriggerHandler(); kmth.sendKartPartnerPublicationNotification(Trigger.New[0].Id); kmth.sendKartInternalPublicationNotification(Trigger.New[0].Id); } //} } }
As i understand the log, the trigger is not called when the article passed the approval process and is published.
How can i solve this issue?
thanks
Peter