To show catalog variables at the time of approval on esc portal

sachinmishr
Tera Contributor

Hi Team,
We are looking for a solution on to show specific catalog variables at time of approval by approver to fill before approving the ritm . Right now we are giving users to itil access to fill the required variables and then approve from sow view. 
We are trying to make this by not giving itil role to approver but to make requried variable editable on ESC portal and allowing them approve from esc portal. By this we will avoid giving ITIL access .

10 REPLIES 10

Ratnakar7
Mega Sage

Hi @sachinmishr ,

By default, approvers in ESC only see approval details, not editable catalog variables. Avoid giving ITIL role just for variable editing - that role grants broader access than needed.
You'll need to extend the approval widget/page in ESC to surface and allow editing of selected variables.


1. Identify the Approval Widget

  • In ESC, approvals are typically handled by widgets such as sc_request_approval or a custom approval widget.

  • You’ll extend this widget to fetch and display catalog variables tied to the RITM.

 

2. Fetch Catalog Variables (Server Script)

Use the widget’s server script to query variables from the RITM:

 

Example:

(function() {
  var ritmSysId = $sp.getParameter('sys_id');
  var gr = new GlideRecord('sc_item_option_mtom');
  gr.addQuery('request_item', ritmSysId);
  gr.query();

  data.variables = [];
  while (gr.next()) {
    var opt = gr.sc_item_option.item_option_new.getRefRecord();
    data.variables.push({
      name: opt.name.toString(),
      label: opt.question_text.toString(),
      value: gr.value.toString(),
      sys_id: opt.sys_id.toString()
    });
  }
})();

 

This collects variables linked to the RITM and passes them to the client side.

 

3. Render Variables in the Widget (HTML)

On the client side, display the variables as editable fields:

<div ng-repeat="v in c.data.variables">
  <label>{{v.label}}</label>
  <input type="text" ng-model="v.value" />
</div>

This makes variables editable in the ESC portal.

 

4. Save Updates Before Approval(Client Controller)

When the approver clicks Approve, capture the updated variable values and send them back to the server:

c.saveVariables = function() {
  $http.post(spUtil.getWidgetURL('update_variables'), {
    ritmSysId: c.data.ritmSysId,
    variables: c.data.variables
  }).then(function(response) {
    // proceed with approval after saving
    c.approveRequest();
  });
};

 

5. Update Variables (Server Script for Save)

Create a small server script to update variable values:

(function(inputs, outputs) {
  var ritmSysId = inputs.ritmSysId;
  var vars = inputs.variables;

  vars.forEach(function(v) {
    var gr = new GlideRecord('sc_item_option_mtom');
    gr.addQuery('request_item', ritmSysId);
    gr.addQuery('item_option_new', v.sys_id);
    gr.query();
    if (gr.next()) {
      gr.value = v.value;
      gr.update();
    }
  });
})(inputs, outputs);

 

 

Thanks,
Ratnakar

 

 

sachinmishr
Tera Contributor

Hi @Ratnakar7 ,
I am going to implement this in my dev instance . I will reach out to you if i face any issues.
Thank you for the support on this.

Ankur Bawiskar
Tera Patron

@sachinmishr 

variables details are already available OOTB on esc when approver sees RITM on My Tasks page

is that not visible for your user?

AnkurBawiskar_0-1767000922036.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,
Variables are showing but in read only mode and we are asking few mandatory variable questions at the time of approval from approver so for that we are giving ITIL access to approvers to fill variables in sow view.