How to display multi-row variable set in approval ticket in UI16?

Ben Benjamin
Tera Expert

Hello Community,

When submitting a service catalog item form that contains a multi-row variable set, such variable set does not appear in associated approval tickets when accessed through UI16 (image below). Has any one found a solution to this issue?

find_real_file.png

Thanks,

Ben Benjamin.

5 REPLIES 5

Michael Jones -
Giga Sage

Based on what you can find here: 

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-manage...

  • A multi-row variable set is supported in the variable summarizer only in Service Portal.
  • You cannot set Global as True for any variable that belongs to a multi-row variable set. So, a multi-row variable set is not available in catalog tasks.

I don't believe you'll find a precise solution for this, as for all intents and purposes, this is behavior as designed. 

I did however find this article: https://community.servicenow.com/community?id=community_article&sys_id=c70c9e3adbeb6f001089e15b8a961...

This provides some insight into how to format an email or a description field with the values, which you might be able to adapt to your purposes.

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Ben Benjamin
Tera Expert

I also found the variables are completely missing from an approval ticket when viewed from the agent workspace (image below). Does anyone know how to add the approval summarizer or variable editor or anything similar to show the variables from the related RITM?

find_real_file.png

 

staticCrash
Tera Guru

Hello,

Here's how I did it:

Code placement:

New UI Macro that calls a new script Include.  The new UI Macro is called by the existing Variable Summarizer via a g:call

 

The Script include returns variable data, the new UI Macro parses out any MRVSs Into a HTML table.

Script Include:

Name:  GetMultiRow

Description: Called by UI macros in the Approval Var summarized.  This is to get Multi Row Var sets

Application: Global

Accessible from: All application scopes

Client Callable: Yes

Spoiler

var GetMultiRow = Class.create();

GetMultiRow.prototype = {

 

    getMRVs: function(sysID) {

             

        var jay = [];

        var ret = [];

 

        var gr = new GlideRecord("sc_req_item");

        gr.addQuery("sys_id", sysID);

        gr.query();

        while (gr.next()) {

 

            jay = new GlobalServiceCatalogUtil().getVariablesForTask(gr, true);

 

            for (var i = 0; i < jay.length; i++) {

                if (jay[i].multi_row) {

                    ret.push(jay[i]);

 

                }

 

            }

 

        }

return ret;

 

 

    },

 

};

 

UI Macro:

Name: approval_multi_row_variable_summary

Description: Returns the MRVSs for a giving reqest / task

Application: Global

Spoiler

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

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

 

 

<g:evaluate jelly="true">

var sys_id;

 

if (!JSUtil.nil(jelly.jvar_sc_req_item))

sys_id = jelly.jvar_sc_req_item;

if (!JSUtil.nil(jelly.jvar_sc_task))

sys_id = jelly.jvar_sc_task;

 

 

var getMRV = new global.GetMultiRow();

 

var mrvs = getMRV.getMRVs(sys_id);         

 

var ret = [];

var row;

ret.push('<table cellspacing="0" cellpadding="0"  >');

    for (var i = 0; i &lt; mrvs.length; i++) {

row = '';

        if (mrvs[i].multi_row) {

row ='<tr><td colspan="2"><b>' + mrvs[i].label + '</b></td></tr>';

 

            for (var j = 0; j &lt; mrvs[i].table_variable.length; j++) {

                for (var k = 0; k &lt; mrvs[i].table_variable[j].length; k++) {

row +='<tr><td>'+mrvs[i].table_variable[j][k].label + '</td><td>' +

mrvs[i].table_variable[j][k].display_value +'</td></tr>';

 

 

                  

                }

 

            }

 

        }

 

ret.push(row);

 

 

 

    }

ret.push('</table>');

 

 

 

</g:evaluate>

 

<ul>

<j:forEach var="jvar_label" items="${ret}">

 

 

<g:no_escape>

 

${jvar_label}                

</g:no_escape>

 

 

 

 

</j:forEach>

 

</ul>

 

 

 

 

 

 

</j:jelly>

Existing UI Macro:

Name: approval_variable_summary

Add this code after ~ line 17

Spoiler

<g:call function="approval_multi_row_variable_summary.xml" question_name="${task.sys_id}" question_help_tag="${smart_description}"

                                sc_req_item="${task.sys_id}" help_class="${jvar_line_color}" />

Chad Johnson
Tera Contributor

@staticCrash This code was extremely helpful in resolving a last minute issue identified while testing before a release.  I really appreciate you contributing this to the SN Community.