RITM stage in form view does not match workflow stage


Description

Setting stage name in the workflow does not update the stage name shown in the RITM form view.

Steps to Reproduce

1. Open an OOB workflow (such as "Service Catalog Item Request"), choose "Properties" option.
2. Under "Stages" tab, change the Stage Name from "Completed" to "Closed" [do not change its value]. Save this change.
3. Edit this workflow and before the "End" activity add a new "Set Values" activity whose Stage is set to "Closed" and set following fields:
"Active" field to "false" and
"state" field to "Closed Complete"
4. Save the workflow
5. Place a request for a catalog item that uses this workflow (such as "Standard Laptop") and once the workflow completes observe the RITM stage it is set to "Completed" instead of "Closed" while the workflow context has Stage set to "Closed"

Workaround

After carefully considering the severity and frequency of the issue, and the cost and risk of attempting a fix, it has been decided to not address this issue in any current or near future releases. We do not make this decision lightly, and we apologise for any inconvenience.

The workaround is to edit the Script Include "WorkflowStages" ( /sys_script_include.do?sys_id=4bffd426c0a80067321762d21c1864a8 ):

1) Modify line # 439 from:
c = this.choice.add("complete", gs.getMessage("Completed"));

To:
c = this.choice.add("complete", gs.getMessage(this._workflowStageNameForValue("complete", "Completed"))); // workaround PRB1383134

2) Add the following function:
// workaround PRB1383134 -- return the workflow specific name for stage with value, otherwise return default
_workflowStageNameForValue: function(stageValue, defaultValue) {
var gr = new GlideAggregate('wf_stage');
gr.addQuery("workflow_version", this.workflowVersion);
gr.addQuery("value", stageValue);
gr.query();
if (gr.next())
return gr.name;
return defaultValue;
},
// end workaround PRB1383134


Related Problem: PRB1383134