How to hide uncheck variables from service portal

jyotisaroj
Tera Contributor

Hi,

We have a requirement for multiple selection, so we have created the variables of type checkbox, now when the request is submitted the unchecked variable is visible in the Additional details of esc portal. 
I have gone through the solution of How to hide unchecked checkbox variable on Self Portal.  
Now I have clone the variable summarizer widget and made the changes, but I need a help on how to call this widget for my Service Catalog, what are steps for calling the Copy of Variable summarizer and how to test it.

3 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@jyotisaroj 

the link you shared already has working solution.

Did you update this record? try giving your custom widget here

ticket page widget summarizer.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

@jyotisaroj adding to my previous mail 

1000021607.jpg

 

Change the type to custom and widget  field. Your widget, use this only if your widget is correctly configured. Else use "Variables read only as recommended by SN"

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

View solution in original post

@jyotisaroj 

this worked for me in the cloned widget.

HTML: No change here actually

<div ng-if="c.data.variables.length > 0" ng-init="c.variable_toggle = c.toggle">
  <button class="btn variables-toggle-btn" aria-expanded="{{c.variable_toggle}}" aria-label="{{data.ariaLabel}}" ng-click="c.variable_toggle = !c.variable_toggle" ng-if="!c.hide_control">
    <span style="font-size: 12px;" class="glyphicon" ng-class="c.variable_toggle ? 'glyphicon-chevron-down' : 'glyphicon-chevron-up'"></span>
    {{data.label}}
  </button>

  <div ng-if="c.variable_toggle" id="variables-toggle" aria-hidden="{{!c.variable_toggle}}">
    <hr role="presentation" ng-if="!c.hide_control">
    <div class="m-b break-word" ng-repeat="variable in c.data.variables">
      <label class="m-t-xs m-b-none text-muted"><b>{{::variable.label}}</b></label>
      <div ng-if="!variable.multi_row">
        <div ng-switch="variable.type">
          <!-- 27 is type URL, 33 is type Attachment -->
          <a ng-switch-when="27" class="pre-wrap" title="{{::variable.label}}" href="{{::variable.display_value}}" target="_blank">{{::variable.display_value}}</a>
          <span ng-switch-when="33" class="file-attachment">
          	<a ng-if="::variable.state != 'not_available'" class="pre-wrap" title="{{::variable.label}}" href="javascript&colon;void(0);" ng-click="scanAttachment(variable)" aria-label="${Download {{variable.display_value}}}">{{::variable.display_value}}</a>
            <span ng-if="::variable.state == 'not_available'" class="error">
							<a class="pre-wrap" title="{{::variable.label}}" href="javascript&colon;void(0);" ng-click="scanAttachment(variable)" aria-label="${File {{variable.display_value}} failed security scan}">{{::variable.display_value}}</a>
             	(${File failed security scan})
            </span>
          </span>
          <span ng-switch-default class="pre-wrap">{{::variable.display_value}}</span>
        </div>
      </div>
      <div ng-if="variable.multi_row">
        <a href="javascript&colon;void(0)" id="{{ 'popoverLink' + $index }}" class="hidden-xs" aria-haspopup="true" aria-expanded="false" ng-click="c.togglePopover($index)"
         uib-popover-template="'sp_multirow_vs_summarizer.html'" popover-title="{{variable.label}}" popover-placement="auto top" popover-append-to-body="true" popover-trigger="none" popover-is-open="c.isPopoverOpen[$index]">{{::c.getMrvsLink(variable)}}</a>
        <a href="javascript&colon;void(0)" class="visible-xs" ng-click="c.openMrvsModal(variable)">{{::c.getMrvsLink(variable)}}</a>
      </div>
    </div>
  </div>
</div>

Server Script: changes made here

(function() {
    data.label = options.label || gs.getMessage("Options");
    if (options.task)
        data.ariaLabel = gs.getMessage("{0} for {1}", [data.label, options.task]);
    else
        data.ariaLabel = data.label;
    if (options.variables) {
        data.variables = filterVariables(options.variables);
        return;
    }
    data.labelClose = gs.getMessage("Close");
    var tableName = options.table || $sp.getParameter('table');
    var sysId = options.sys_id || $sp.getParameter('sys_id');

    if (!new global.SPWidgetAccessControl().hasPublicAccess(tableName, $sp, options, input)) {
        gs.warn("Deny access to table which is not public: " + tableName);
        data.isValid = false;
        return;
    }

    var record = sn_std_tkt_api.TicketConfig.getTicketRecord(tableName, sysId);

    if (record == null)
        return;

    data.canRead = record.canRead();
    if (!data.canRead)
        return;

    data.variables = filterVariables(new GlobalServiceCatalogUtil().getVariablesForTask(record, true));

})();

function filterVariables(variables) {
    if (variables == null || variables.length == 0)
        return variables;

    var filteredVariables = [];
    variables.forEach(function(variable) {

        if (variable.visible_summary) {
            // push the variable only when it's checkbox and true
            if (variable.type.toString() == '7' && variable.display_value.toString() == 'true')
                filteredVariables.push(variable);
            else if (variable.type.toString() != '7') // push all other variables as it is
                filteredVariables.push(variable);
        }

    });

    return filteredVariables;
}

Server Side Script highlighted: push checkbox only when value is true

 

AnkurBawiskar_0-1743163630685.png

 

RITM has unchecked variable in variable editor

 

AnkurBawiskar_2-1743164025528.png

 

Unchecked variable is hidden on portal:

 

AnkurBawiskar_1-1743163938587.png

 

Standard ticket config record:

AnkurBawiskar_3-1743164143388.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

15 REPLIES 15

jcmings
Mega Sage

You need to update the widget listed on the Standard Ticket Configuration (Standard Ticket > Standard Ticket Configuration). Open the record for your table and then view the related list for the Tab Configurations. Within the "Additional details" tab you should be able to specify your custom widget.

Shivalika
Mega Sage

Hello @jyotisaroj 

 

Can you share screenshot ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Hi @Shivalika

Here are the screenshot 

jyotisaroj_0-1743157125645.png

If the checked variable is not selected the it is visible in the esc portal of Additional Details

Hello @jyotisaroj 

 

Did you replace the Type in Tab Configuration with your new custom widgets ? 

 

1000021605.jpg

 

Please try and let me know.

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY