Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
Answered

How to make Reason for Rejection dialog appear in custom Knowledge base form?

Posted on by 112

I duplicated the default Form for KB articles to customize layout a bit and fields. However, the Reason for rejection slide out dialog is not triggered when changing the Review status to Rejected. It works in the Default form.

I've looked at events and triggers etc but cannot find where this functionality is to be able to replicate it. We also have 2 approval steps, so would like that to work there as well.

Screen-Shot-2022_2D00_03_2D00_02-at-10.09.22-AM.png

Categories:
  • JustRhonda Profile Picture
    JustRhonda 50 on at
    How to make Reason for Rejection dialog appear in custom Knowledge base form?
    I'm glad someone had the same question I did. I don't like the answer (not low-code) but at least I know it isn't a simple solution. I can't even find the library when I search the Default Solution Web Resources. 
  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to make Reason for Rejection dialog appear in custom Knowledge base form?

    Hi HangryMapache,

    I created a custom form as you did and it also not works for me.  Then I find the code in the library(msdyncrm_/KnowledgeManagement/KnowledgeArticle/KnowledgeArticleMainSystemLibrary.js) which is used to open this dialog. So I created an onchange event on Review field and hide the Review field on the form. And it could work for me now.

    Form Setting:

    7065.Snipaste_5F00_2022_2D00_03_2D00_11_5F00_16_2D00_30_2D00_04.png

    Onchange code:

    function onchange(eventContext) {
    alert(1);
    var formContext = KnowledgeManagement.KnowledgeArticleUtility.getFormContext(eventContext),
    reviewState = formContext.data.entity.attributes.get(KnowledgeManagement.Review),reviewOptionSetPreviousSelection=null;
    if (reviewState.getValue() == KnowledgeManagement.KnowledgeArticleReviewState.Rejected) {
    var primaryAuthorLookupAttribute = formContext.getAttribute(KnowledgeManagement.PrimaryAuthorId),
    guidForPrimaryAuthorId = "";
    if (primaryAuthorLookupAttribute) {
    var primaryAuthorLookupAttributeValue = primaryAuthorLookupAttribute.getValue();
    if (primaryAuthorLookupAttributeValue && primaryAuthorLookupAttributeValue.length > 0) guidForPrimaryAuthorId = primaryAuthorLookupAttributeValue[0].id
    }
    var options = {
    height: 500,
    width: 400,
    position: 2
    },
    dialogParams = {};
    dialogParams[KnowledgeManagement.ParamEntityId] = formContext.data.entity.getId();
    dialogParams[KnowledgeManagement.ParamLastButtonClicked] = KnowledgeManagement.DialogOkId;
    dialogParams[KnowledgeManagement.ParamPrimaryAuthorId] = guidForPrimaryAuthorId;
    dialogParams[KnowledgeManagement.ParamReview] = reviewState.getValue();
    Xrm.Navigation.openDialog(KnowledgeManagement.RejectKnowledgeArticleDialog, options, dialogParams).then(function(successParameter) {
    var reviewState = formContext.getAttribute(KnowledgeManagement.Review);
    if (reviewState)
    if (successParameter.parameters[KnowledgeManagement.ParamLastButtonClicked] == KnowledgeManagement.DialogOkId) reviewOptionSetPreviousSelection = reviewState.getValue();
    else reviewState.setValue(reviewOptionSetPreviousSelection)
    }, null)
    } else if (reviewState.getValue() == KnowledgeManagement.KnowledgeArticleReviewState.Approved) {
    var onApproveDialogCancelCallback = function() {
    var reviewOptionSet = reviewState;
    reviewOptionSet.setValue(reviewOptionSetPreviousSelection)
    },
    onApproveDialogOkCallback = function(response) {
    var reviewOptionSet = reviewState;
    reviewOptionSetPreviousSelection = reviewOptionSet.getValue()
    };
    KnowledgeManagement.KnowledgeArticle.CommandActions.approveArticle(formContext, onApproveDialogOkCallback, onApproveDialogCancelCallback)
    } else reviewOptionSetPreviousSelection = reviewState.getValue()
    };

    Result:

    kb.gif

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans