The CreatorCon Call for Content is officially open! Get started here.

how to remove "Request Approved" Stage from RITM

varunp
Tera Guru

how to remove "Request Approved" Stage from RITM which automatically comes from request workflow.

find_real_file.png

1 ACCEPTED SOLUTION

Yea, I made a mistake.   I'd update the "Workflow-driven" Column Renderer by adding;



var currentChoice = choices.getChoice(0).getValue();

      gs.log(choices.getChoice(0));


      if(currentChoice == "approved" || currentChoice == "waiting_for_approval"){


      choices.removeChoice(0);


      }



This will remove these choices



So the first evaluate block should have this in it.



// get the api
var api = new SNC.RendererAPI('$[jvar_renderer]');


// build the full set of choices including subflows
// if we have an 'answer' global then it was populated
// by a getChoices bus-rule so use that otherwise
// use the renderer api to get them from the workflow
// generated choices in the context.
var choices = api.getAllWorkflowChoices(current, jelly.jvar_ref);
api.addIconsAndStatus(choices);

      var currentChoice = choices.getChoice(0).getValue();


      gs.log(choices.getChoice(0));


      if(currentChoice == "approved" || currentChoice == "waiting_for_approval"){


      choices.removeChoice(0);


      }


      choices;



Then you'll have to change the renderer on the workflow to use "Workflow Driven"



find_real_file.png



Then it should look like this for items using that workflow;



Cart;


find_real_file.png



List;


find_real_file.png


View solution in original post

13 REPLIES 13

Jace Benson
Mega Sage

This is a common ask,   A lot of folks want to do this but in the past I've never seen it done.   Today I took the time to read into it.   I just removed them from my items and here's how I did it.



1.   Add an ACL on column_renderer to allow admin to create records.


2.   Add an ACL on column_renderer to allow admin to write to * fields.


3.   Here you have a choice, make a new renderer, or modify the OOB one.


I modified the OOB one to get this working, you choose the "Renderer" in the workflow.



Below is the code for the SCReqItemRenderer


Line 96 and 120 are the only modifications.



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">



<j:set var="jvar_renderer" value="Legacy"/>



<g:choice_list ref="$[jvar_ref]"/>


<j:set var="jvar_workflow_icons" value="WorkflowIcons"/>



<g:evaluate var="jvar_hasicons"     expression="$[SAFE:jvar_ref].hasAttribute('icons');" />


<g:evaluate var="jvar_icons"           expression="$[SAFE:jvar_ref].getAttribute('icons');" />



<j:if test="$[jvar_hasicons]" >


      <j:set var="jvar_workflow_icons" value="$[jvar_icons]" />


</j:if>



<g:evaluate var="jvar_choices" jelly="true" object="true">


      var choices = jelly.jvar_choices;



      // Use the API to translate


      var api = new SNC.RendererAPI('$[jvar_renderer]');


      api.internationalizeChoices(choices);



      try {


              var wfw = new $[SAFE:jvar_workflow_icons]('$[jvar_ref]');


              choices = wfw.process(jelly.jvar_choices);


      } catch (e) {


              // could have an issue during the first upgrade


              // before it gets this widget


      }



      choices;


</g:evaluate>



<g:evaluate var="jvar_expand_id" jelly="true">


      // Create a unique id across multiple workflow columns in the same table.


      var expand_id = jelly.jvar_workflow_id + '_' + jelly.jvar_ref;


      var parts = jelly.jvar_ref.split('.');


      if (parts.length >= 2) {


              parts[0] = '';


              expand_id = jelly.jvar_workflow_id + parts.join('_');


      }


      expand_id;


</g:evaluate>



<!-- called when you have successfully ordered an item from service catalog -->


<j:set var="jvar_t" value="$[jvar_ref]" />


<table id="workflow.$[jvar_expand_id]" border="0" cellpadding="0" cellspacing="0"


            style="margin-top: 2px; background-color: transparent;" >



  <tr id="$[jvar_expand_id]">



  <!-- +/- expander box   -->


  <td valign="top" style="background:transparent">


      <span id="renderer" style="display:none">$[jvar_renderer]</span>


      <span id="workflowfilter.$[jvar_expand_id]">


        <a tabindex="0" onclick="togglePreference('$[jvar_expand_id]');" aria-controls="$[jvar_expand_id]">


              <img id="filterimg.$[jvar_expand_id]" src="images/filter_hide16.gifx" alt="${gs.getMessage('Expand')}"


                        border="0" title="${gs.getMessage('Expand')}"


                        style="margin-top: 1px; margin-bottom: 1px;"/>


          </a>


  </span>


  </td>


  <td nowrap="true" style="background-color:transparent">


  <j:forEach var="jvar_choice" items="$[jvar_choices]">


      <g:evaluate var="jvar_item_idx" jelly="true">


              var itemIdx = jelly.jvar_item_idx;


              if (itemIdx == '' || typeof itemIdx == "undefined")


                      itemIdx = 1;


              else


                      itemIdx = parseInt(itemIdx) + 1;


              itemIdx;


      </g:evaluate>


      <g:evaluate var="jvar_choice_visible" jelly="true">


              var isVisible = true; //jelly.jvar_choice.getParameter('visible')+'' == 'true';


              if (jelly.jvar_choice.value == '')


                    isVisible = false;


              isVisible;


      </g:evaluate>



      <!-- we only want to display values that are not empty and are 'visible' -->


      <j:if test="$[jvar_choice_visible]">


          <g:evaluate var="jvar_image" jelly="true">


                  var imgsrc = (jelly.jvar_choice.image+'').split(' ');


                  imgsrc = imgsrc.length ? imgsrc[0] : imgsrc;


                  imgsrc;


          </g:evaluate>


          <!-- no image, provide default -->


          <j:if test="$[jvar_choice.image == '']">


              <j:if test="$[jvar_choice.selected]">


                  <j:set var="jvar_image" value="icon-check-circle"/>


              </j:if>


              <j:if test="$[!jvar_choice.selected]">


                      <j:set var="jvar_image" value="icon-empty-circle"/>


              </j:if>


          </j:if>


              <j:if test="$[jvar_choice.value != 'approved']">


             


          <span id="stage.$[jvar_item_idx].$[jvar_expand_id].$[jvar_choice.value]" stage="true" selected="$[jvar_choice.selected]" aria-expanded="false">



          <g:set_if test="$[GlideMobileExtensions.runningTablet() || gs.getProperty('glide.ui.doctype') == 'true']" var="jvar_display_type"


                              true="inline-block" false="inline" />




              <table border="0" cellpadding="0" cellspacing="0" class="stageiconsinner"


                            style="background-color: transparent; display: $[jvar_display_type];">



                  <tr id="$[jvar_expand_id]">


                      <td style="border: 0px; padding:2px; background-color: transparent;">


                              <g:set_if var="jvar_title" test="$[jvar_choice.getParameter('title') == undefined]" true="$[jvar_choice.label]" false="$[jvar_choice.getParameter('title')]" />


                              <img id="stage.$[jvar_item_idx].$[jvar_expand_id].$[jvar_choice.value].image" title="$[jvar_title]"


                                        class="nopadding" src="images/heisenberg_icons/stage_icons/$[jvar_image].png" alt="$[jvar_choice.label]" aria-hidden="true"/>


                      </td>


                      <td id="stage.$[jvar_item_idx].$[jvar_expand_id].$[jvar_choice.value].text" style="display: none; z-index: -1; background-color: transparent;" nowrap="true">


                              <!-- IE quirkaround -->


                              <span style="margin-right: 3px;"><img src="images/s.gifx" alt="" aria-hidden="true"/></span>$[jvar_choice.label]


                      </td>


                  </tr>


              </table>


          </span>


              </j:if>


      </j:if>


  </j:forEach>


  </td>


</tr>


</table>



<g:evaluate var="jvar_expanded_pref" expression="gs.getPreference('workflow.expanded.$[jvar_ref_parent]')" />



<j:if test="$[jvar_expanded_pref]">


      <script>toggleItems('$[jvar_expand_id]');</script>


</j:if>




</j:jelly>


I am getting below error



find_real_file.png


I changed line 96 to   <j:if test="$[jvar_choice.value != 'approved']">  



But still i am seeing the that stage


Yea, I made a mistake.   I'd update the "Workflow-driven" Column Renderer by adding;



var currentChoice = choices.getChoice(0).getValue();

      gs.log(choices.getChoice(0));


      if(currentChoice == "approved" || currentChoice == "waiting_for_approval"){


      choices.removeChoice(0);


      }



This will remove these choices



So the first evaluate block should have this in it.



// get the api
var api = new SNC.RendererAPI('$[jvar_renderer]');


// build the full set of choices including subflows
// if we have an 'answer' global then it was populated
// by a getChoices bus-rule so use that otherwise
// use the renderer api to get them from the workflow
// generated choices in the context.
var choices = api.getAllWorkflowChoices(current, jelly.jvar_ref);
api.addIconsAndStatus(choices);

      var currentChoice = choices.getChoice(0).getValue();


      gs.log(choices.getChoice(0));


      if(currentChoice == "approved" || currentChoice == "waiting_for_approval"){


      choices.removeChoice(0);


      }


      choices;



Then you'll have to change the renderer on the workflow to use "Workflow Driven"



find_real_file.png



Then it should look like this for items using that workflow;



Cart;


find_real_file.png



List;


find_real_file.png


YES IT WORKS!!!

Thank you for sharing this!