Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Disable/Hide Business Process flow Set Active or Next stage button

Posted on by 1,217

Hi All,

I have a requirement to validate the current user whether is authorize to move to next stage of in my custom business process flow. How can I disable it by using javascript?

I had checked seem business rule cannot achieved this requirement.

Thanks.

Regards,
Teh

  • yassin sayed Profile Picture
    yassin sayed 85 on at
    RE: Disable/Hide Business Process flow Set Active or Next stage button

    function HideSetAcgtiveButton(executionContext) {

       var formContext = executionContext.getFormContext();

       formContext.data.process.addOnStageSelected(onStageClicked);

    }

    function onStageClicked(executionContext) {

       var formContext = executionContext.getFormContext();

    var hide = true;

    var interval = null;

    interval = setInterval(function () {

           var element = parent.document.getElementById("MscrmControls.Containers.ProcessStageControl-businessProcessFlowFlyoutFooterContainer");

           if (element != null && hide == true) {

               hide = false;

               element.style.display = "none";

               clearInterval(interval);

           }

       }, 10);

    }

  • yassin sayed Profile Picture
    yassin sayed 85 on at
    RE: Disable/Hide Business Process flow Set Active or Next stage button

    function HideSetAcgtiveButton(executionContext) {

       var formContext = executionContext.getFormContext();

       formContext.data.process.addOnStageSelected(onStageClicked);

    }

    function onStageClicked(executionContext) {

       var formContext = executionContext.getFormContext();

    var hide = true;

    var interval = null;

    interval = setInterval(function () {

           var element = parent.document.getElementById("MscrmControls.Containers.ProcessStageControl-businessProcessFlowFlyoutFooterContainer");

           if (element != null && hide == true) {

               hide = false;

               element.style.display = "none";

               clearInterval(interval);

           }

       }, 10);

    }

  • Suggested answer
    RE: Disable/Hide Business Process flow Set Active or Next stage button

    Hi Teh,

    Maybe you can't remove this button using a supported method, I need to research more about it.

    It's possible to use two ways to 'prevent' the customer move:

    a. On security role, if you uncheck to write on permission on business process flow.

       - In this scenario when the system user try to move, will receive an error message, based on permission insufficient.  

    b. Use a javascript funcion moveprevious based on this reference docs.microsoft.com/.../moveprevious.

     - In this scenario is need to use the function addonstagechange to check some changes on stage and moveprevious. To check addonstagechange, you could check this reference docs.microsoft.com/.../addonstagechange.

    Let me know if these information help you.

  • YA TEH Profile Picture
    YA TEH 1,217 on at
    RE: Disable/Hide Business Process flow Set Active or Next stage button

    Hi Carlos,

    I did tried using formContext.ui.process however, this function seem is hide the whole business process flow control.

    What I want is to hide the button of each stage based on user validation.

    stage-button.jpg

    I can't any reference related to the Next stage button.

    Thanks.

    Regards,
    Teh

  • Suggested answer
    RE: Disable/Hide Business Process flow Set Active or Next stage button

    Hi Ya Teh,

    Maybe could you check some user information using - var userSettings = Xrm.Utility.getGlobalContext().userSettings - Reference: docs.microsoft.com/.../usersettings

    Using this sample you can validate UserID, SecurityRoles or some other information to validate the current user.

    After it, based on validation is possible to apply setVisible on Business Process Flow using docs.microsoft.com/.../formcontext-ui-process.

    Another possibility is to use synchronous workflow to come back based on some validation, in this situation, the customer can change but system will revert it.

    Let me know if the information above is valid for your scenario.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans