Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Add review/reject/choose-next-reviewer options in workflow

Avatar

Employee

Hello All,

We have a requirement to choose Add review/reject/choose-next-reviewer options in workflow in the workflow to choose reviewer also , I need a drop down that contains 

- approve 

- reject

2nd dropdown - populates the list of users in given group.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

To proceed to the next step based on the user's selection, you can add the code in the event handler for the "Approve" option in the dropdown. 

 

Based on the provided workflow diagram, it seems like you have a form with a dropdown for the user to select an option. When the user selects "Approve" from the dropdown, you want to proceed to the next step.

 

To achieve this, you can add an event listener to the dropdown element and handle the "change" event. In the event handler, you can check the selected value and perform the necessary actions to proceed to the next step.

 

// Assuming you have a dropdown element with id "approvalDropdown"

const approvalDropdown = document.getElementById("approvalDropdown");

 

approvalDropdown.addEventListener("change", function() {

  const selectedOption = approvalDropdown.value;

  

  if (selectedOption === "Approve") {

    // Code to proceed to the next step

    // Add your code here to perform the necessary actions

  }

});

 

 

You can place this code in the JavaScript file or script tag where you handle the logic for your form. Make sure to replace "approvalDropdown" with the actual id of your dropdown element.



View solution in original post

4 Replies

Avatar

Community Advisor

Hi @SateeshRe 
To implement this workflow with the dropdowns you described, you can use a combination of HTML, JavaScript, and the appropriate workflow APIs for your platform.

 

<!-- First dropdown for review decision -->
<select id="review-decision">
  <option value="approve">Approve</option>
  <option value="reject">Reject</option>
</select>

<!-- Second dropdown for reviewer selection -->
<select id="reviewer-selection"></select>

<script>
  // Populate the second dropdown with a list of users in a given group
  function populateReviewerDropdown(groupName) {
    // Use the appropriate workflow API to get a list of users in the given group
    var users = getGroupMembers(groupName);
    
    // Get a reference to the second dropdown
    var reviewerDropdown = document.getElementById('reviewer-selection');
    
    // Clear any existing options
    reviewerDropdown.innerHTML = '';
    
    // Add an option for each user in the group
    users.forEach(function(user) {
      var option = document.createElement('option');
      option.value = user.id;
      option.text = user.name;
      reviewerDropdown.appendChild(option);
    });
  }
  
  // Call the populateReviewerDropdown function when the first dropdown changes
  var reviewDecisionDropdown = document.getElementById('review-decision');
  reviewDecisionDropdown.addEventListener('change', function() {
    if (reviewDecisionDropdown.value === 'reject') {
      populateReviewerDropdown('reviewers');
    } else {
      // Clear the second dropdown if the first dropdown is not set to "reject"
      var reviewerDropdown = document.getElementById('reviewer-selection');
      reviewerDropdown.innerHTML = '';
    }
  });
</script>

 

This code assumes that you have a function called getGroupeMembers that returns a list of users in the given group. You will need to replace this function with the appropriate workflow API for your platform.

When the user selects "Reject" in the first dropdown, the populateReviewerDropdown function is called with the name of the group containing the reviewers. This function uses the appropriate workflow API to get a list of users in the group, and populates the second dropdown with an option for each user.

When the user selects "Approve" in the first dropdown, the second dropdown is cleared.



Avatar

Employee

Thanks for the reply,

Lets Say if user selects the Approve, then how can I proceed to the next step.

At what level we have to add this code?

 

SateeshRe_0-1711379983982.png

I want that option by adding another drop down, where should I keep my code.

 

Here is my workflow

 

SateeshRe_1-1711380072997.png

 

Avatar

Correct answer by
Community Advisor

To proceed to the next step based on the user's selection, you can add the code in the event handler for the "Approve" option in the dropdown. 

 

Based on the provided workflow diagram, it seems like you have a form with a dropdown for the user to select an option. When the user selects "Approve" from the dropdown, you want to proceed to the next step.

 

To achieve this, you can add an event listener to the dropdown element and handle the "change" event. In the event handler, you can check the selected value and perform the necessary actions to proceed to the next step.

 

// Assuming you have a dropdown element with id "approvalDropdown"

const approvalDropdown = document.getElementById("approvalDropdown");

 

approvalDropdown.addEventListener("change", function() {

  const selectedOption = approvalDropdown.value;

  

  if (selectedOption === "Approve") {

    // Code to proceed to the next step

    // Add your code here to perform the necessary actions

  }

});

 

 

You can place this code in the JavaScript file or script tag where you handle the logic for your form. Make sure to replace "approvalDropdown" with the actual id of your dropdown element.



Avatar

Community Advisor

@SateeshRe , Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.