Process Activity Routing Based on Buttons Instead of Select Box

Introduction

In many form-based workflows, the decision for the next action is often made using a select box. However, a design with individual buttons can offer a more intuitive and user-friendly interface for some users. This approach can be particularly effective if users are accustomed to systems with similar designs.

How does it work?

This script replaces a select box with individual buttons for each option. When a button is clicked, it sets the value of the hidden select box and triggers the form submission. This method improves user experience by providing clear, actionable options directly.




Steps to Implement:

  1. Find the name of the select box you want to replace with buttons. Below, watch the screenshot to identify the correct element name.

  2. Insert the following code into the Custom HTML section of your form. Update the selectBoxName variable with the name of your select box.

    Code:

    <script type="text/javascript">
    var selectBoxName = "approval_request_approval_action_status";
    $(function(){
        $(FormUtil.getField(selectBoxName)).parent().hide();
        $(FormUtil.getField(selectBoxName)).children().each(function(){
            if($(this).attr("value") != ""){
                var cssClass = $(".form-button:last").attr("class");
                var button = "<div type=\"button\" class=\"form-cell\"><button class=\"" + cssClass + "\" onclick=\"completeWithVariable($(this));return false;\" value=\"" + $(this).attr("value") + "\">" + $(this).text() + "</button></div>";
                $(".form-button:last").after(button);
            }
        });
    });
    function completeWithVariable(obj){
        $(FormUtil.getField(selectBoxName)).val($(obj).val());
        $("#assignmentComplete").trigger("click");
    }
    </script>
    <style type="text/css">
        input#assignmentComplete{
            display: none;
        }
    </style>

Download sample app

Download the sample app demonstrating form buttons for approval/rejection in Joget Workflow Enterprise v6:
Created by Julieth Last modified by Aadrian on Dec 13, 2024