Skip to main content

Notifications

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 49 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

Helpful resources

Quick Links

Upcoming TechTalk: Copilot Capabilities…

Review the Copilot features that are currently available in Dynamics 365 Finance…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,414 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,394 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans