Display description on my requests page is the Service portal

Fraggle Rock
Tera Expert

HI there we are want to display the incident description and and not just  the short description when a user views their incidents on the my requests page of the service portal. as the first item on the activity tab as shown below.

what is the best way to do this find_real_file.png

1 ACCEPTED SOLUTION

Kasi Ramanathan
Kilo Guru

Hi @Fraggle Rock 

 

In the Service Portal, Check for the page name as highlighted in the below screenshot.

find_real_file.png

Now, Navigate back to Native UI and Search for Widgets in the Service Portal module. Search for "Ticket Conversation"

find_real_file.png

Open the record. In the Body HTML Template add the below line as highlighted.

<p>{{data.description}}</p>

find_real_file.png

In Server Script, add the below line as highlighted.

data.description = gr.getDisplayValue('description');

find_real_file.png

Click on Update. Now navigate to portal.

View solution in original post

7 REPLIES 7

cashmere
Giga Contributor

Hi, thanks for your help it helps me too

AishwaryaS1
Kilo Sage

Hi Guyz,

 1. For this requirement we need to clone the widget name as " My Requests"  v2.

2. so first you clone the widget and then Pass the name of the widget in the "Instance in Page Editor".

3. For  passing name of widget, go to the service portal and open the request tab.

4. After that press Control + Right click on any one of the request display on the request tab.

5. Once you click Ctrl + Right Click choose "Instance Page Editor"

6. Go to the end of the page which you open now where you will get name of widget just replace that widget name with the new one which you clone and select that.

 

You can directly copy paste my code in the My Requests widget

HTML :

 

<div class="panel panel-default b" ng-init="c.trackPage()">
<div class="panel-heading" ng-show="::!data.is_associated_ticket_tab">
<h2 class="panel-title">{{::data.messages.myRequestsTitle}}</h2>
</div>
<div class="panels-container list-group">
<div ng-show="::!data.is_associated_ticket_tab" class="list-group-item row requests-header-container">
<div class="col-md-3 col-xs-12 m-b-sm fit-content">
<div class="form-inline control-view" ng-if="c.options.show_view == 'true'">
<label class="control-label hidden-xs wrapper-xs " id="label_view" for="view">${View}</label>
<select ng-model="c.viewFilter" id="view" class="sc-basic-select adjust-width" ng-change="c.changeView()" style="width:80%">
<option value="open" selected="true">{{::data.messages.openRequests}}</option>
<option value="close">{{::data.messages.closedRequests}}</option>
</select>
</div>
</div>
<div class="col-md-4 col-xs-12 padding-left-large fit-content">
<div class="input-group" style="width:100%">
<input ng-model="c.filterText" ng-keypress="c.checkEnter($event)"class="form-control" style="width:100%" placeholder="{{data.filterMsg}}" aria-label="{{data.filterMsg}}">
<span class="input-group-btn">
<button class="btn btn-default align-icon" type="button" ng-click="c.search()" title="{{data.filterMsg}}" aria-label="{{data.filterMsg}}">
<i class="fa fa-search"></i>
</button>
</span>
</div><!-- /input-group -->

</div>
</div>
<div ng-if="c.data.request.req_list.length == 0 && !c.filterText" class="panel-body panels-container">
${You do not have any requests}
</div>
<div ng-if="c.data.request.req_list.length == 0 && c.filterText" class="panel-body panels-container">
${Search didn't match any requests}
</div>
<div role="table" ng-if="c.data.request.req_list.length > 0" class="table" aria-label="{{::data.messages.myRequestsTitle}}">
<div ng-show="::!data.is_associated_ticket_tab" role="rowgroup" class="column-headers">
<div role="row" class="list-group-item table-responsive">
<span role="columnheader" class="col-xs-6 padder-r-none padder-l-none">${Request}</span>
<span role="columnheader" class="col-xs-3 padder-r-none padder-l-none">${State}</span>
<span role="columnheader" class="col-xs-3 padder-r-none padder-l-none">${updated_capital}</span>
</div>
</div>
<ul role="rowgroup" class="padder-l-none padder-r-none">
<li role="row" class="list-group-item table-responsive" ng-repeat="item in c.data.request.req_list | limitTo: c.data.lastLimit track by item.sys_id" style="margin:0px" >
<div role="cell" class="col-xs-6 padder-l-none padder-r-none main-column">
<div class="primary-display">
<a href="?id={{::item.url.id}}&table={{::item.url.table}}&sys_id={{::item.url.sys_id}}" sn-focus="{{::item.highlight}}" aria-label="{{::item.display_field}} , {{::item.display_number}}"> {{::item.display_field}} </a>
</div>
<small class="text-muted">
<div class="secondary-display">
<label><b>Short Description: </b></label>
<span>{{::item.short_description}}</span>
</div>
<div ng-repeat="f in item.secondary_displays" class="secondary-display">
<span >{{::f.display_value}}</span>
</div>
</small>
</div>
<div role="cell" class="col-xs-3 padder-l-none padder-r-none state-column">
<div class="state">
<span> {{::item.state}}</span>
</div>
</div>
<div role="cell" class="col-xs-3 padder-l-none padder-r-none updated-column">
<div class="updated">
<i class="fa fa-clock-o" aria-hidden="true" title="${Updated}"></i>
<sn-time-ago timestamp="::item.updated_on"/>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-12 pull-none" ng-if="c.data.hasMore" style="padding-bottom:15px">
<div class="text-a-c" ng-if="c.fetching">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr-only">${Loading more requests}</span>
</div>
<button class="btn btn-default btn-show-more" ng-click="c.loadMore()"> {{::data.messages.showMoreRequests}} </button>
</div>

 

Server Side :

 

(function() {

var localInput = input; //to safeguard pullution of "input" via BR or other scripts

var alsoRequest = false;

var msg = data.messages = {};
msg.myRequestsTitle = options.title? gs.getMessage(options.title) : gs.getMessage('My Requests');
msg.openRequests = gs.getMessage('Open requests');
msg.closedRequests = gs.getMessage('Closed requests');
msg.showMoreRequests = gs.getMessage('Show More Requests');
data.filterMsg = gs.getMessage("Search open requests");

var recordTable = options.record_table || $sp.getParameter("table");
var recordId = options.record_id || $sp.getParameter("sys_id");

data.is_associated_ticket_tab = options.is_associated_ticket_tab;

if (localInput && localInput.view === 'open')
data.filterMsg = gs.getMessage("Search open requests");
else if (localInput && localInput.view === 'close')
data.filterMsg = gs.getMessage("Search closed requests");

data.is_new_order = (($sp.getParameter("is_new_order") + '') === "true");
data.requestSubmitMsg = gs.getMessage('Thank You. Your request has been submitted');

function getField(gr, name) {
var f = {};
var id = gr.getUniqueValue();
gr = new GlideRecord(gr.getRecordClassName());
gr.get(id);
f.display_value = gr.getDisplayValue(name);
f.value = gr.getValue(name);
var ge = gr.getElement(name);
if (ge) {
var ed = ge.getED();
if (ed)
f.type = ed.getInternalType();
f.label = ge.getLabel();
}
return f;
}

function getMyRequestSysIds() {
var ids = {};
var rq_filter = new GlideRecord('request_filter');
rq_filter.addActiveQuery();
if (rq_filter.isValidField('applies_to'))
rq_filter.addQuery('applies_to', 1).addOrCondition('applies_to', 10);
rq_filter.query();
while(rq_filter.next()) {
var tableName = rq_filter.table_name;
if (rq_filter.isValidField('table'))
tableName = rq_filter.table;
var gr = new GlideRecord(tableName);
gr.addQuery(rq_filter.filter);
gr.query();
if (tableName == 'sc_request')
alsoRequest = true;
while(gr.next()) {
var portalSettings = {};
portalSettings.page = rq_filter.portal_page.nil()? '' : rq_filter.portal_page.getDisplayValue() + '';
portalSettings.primary_display = rq_filter.primary_display.nil()? '': rq_filter.primary_display + '';
portalSettings.secondary_displays = rq_filter.secondary_display.nil()? '': rq_filter.secondary_display + '';
ids[gr.sys_id + ''] = portalSettings;
}
}
return ids;
}

// retrieve the request's
var myRequestMap = getMyRequestSysIds();
var taskIDs = Object.keys(myRequestMap);

var gr = new GlideRecordSecure('task');

if (!data.is_associated_ticket_tab) {
if (localInput && localInput.view === 'open')
gr.addActiveQuery();
else if (localInput && localInput.view === 'close')
gr.addQuery('active', 0);
else
        gr.addActiveQuery();
    } else {
            if (recordTable != 'universal_request') {
                //Check if universal_request field is present and it is a universal request
                var taskRecord = new GlideRecordSecure('task');
                taskRecord.get(recordId);
                if (taskRecord.isValid() && !taskRecord.universal_request.nil()) {
                        var qc = gr.addQuery('parent',taskRecord.universal_request);
                        qc.addOrCondition('parent','IN',new sn_uni_req.UniversalRequestUtilsSNC().getChildRequests(taskRecord.universal_request));                        
                }
                else
                        gr.addQuery('parent',recordId);
            }
            else {
                var qc = gr.addQuery('parent',recordId);
                qc.addOrCondition('parent','IN',new sn_uni_req.UniversalRequestUtilsSNC().getChildRequests(recordId));                        
            }
    }

    gr.orderByDesc('sys_updated_on');
    if (localInput && localInput.search_text) {
            var req = [];
            var task = new GlideRecordSecure('task');
            task.addQuery('123TEXTQUERY321', localInput.search_text);
            if (localInput && localInput.view === 'open')
                task.addQuery('active', 1);
            else if (localInput && localInput.view === 'close')
                task.addQuery('active', 0);
            else
                task.addQuery('active', 1);
            task.addQuery('sys_id', taskIDs);
            task.query();

            while(task.next())
                req.push(task.getUniqueValue());
       
            if (alsoRequest) {
                var ritmGR = new GlideRecord('sc_req_item');
                if (localInput && localInput.view === 'open')
                    ritmGR.addQuery('request.active', 1);
                else if (localInput && localInput.view === 'close')
                    ritmGR.addQuery('request.active', 0);
                else
                    ritmGR.addQuery('request.active', 1);
                ritmGR.addQuery('123TEXTQUERY321', localInput.search_text);
                ritmGR.addQuery('request.sys_id', taskIDs);
                ritmGR.query();
                while(ritmGR.next())
                    req.push(ritmGR.getValue('request'));
            }
            gr.addQuery('sys_id', req);
        }
        else
            gr.addQuery('sys_id', taskIDs);
    gr.query();

    data.request = {};

    data.request.req_list = [];
    var recordIdx = 0;    
    var limit = options.items_per_page? options.items_per_page : 15;
    if (localInput && localInput.action == 'fetch_more')
        data.lastLimit = localInput.lastLimit + limit;
    else
        data.lastLimit = limit;
data.hasMore = false;
    while (recordIdx != data.lastLimit && gr.next()) {
        var portalSettings = myRequestMap[gr.getUniqueValue()];
        if (typeof portalSettings == 'undefined')
            portalSettings = {};

        var record = {};
        record.sys_id = gr.getValue('sys_id');
       var request = new GlideRecord('sc_request');
        request.addQuery('sys_id',record.sys_id);
        request.query();
        if(request.next()){
        record.short_description = gr.getValue('short_description');
        }
        if (gr.getRecordClassName() == 'sc_request') {
                var ritm = new GlideRecord("sc_req_item");
                ritm.addQuery("request", gr.getUniqueValue());
                ritm.query();
                if (ritm.getRowCount() == 0)
                    continue;
                if (ritm.getRowCount() > 1)
                    record.display_field = gs.getMessage("{0} requested items", ritm.getRowCount());
                else {
                    ritm.next();
                    record.display_field = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue("short_description");
                }
                record.url = { id: portalSettings.page? portalSettings.page: 'sc_request', table: 'sc_request', sys_id: record.sys_id};
        } else {
                record.display_field = portalSettings.primary_display ? getField(gr, portalSettings.primary_display).display_value : getField(gr, 'number').display_value;
                record.url = { id: portalSettings.page? portalSettings.page :'ticket', table: gr.getRecordClassName(), sys_id: record.sys_id};
        }
        record.display_number = getField(gr, 'number').display_value || '';
        if (portalSettings.secondary_displays) {
            record.secondary_displays = [];
            portalSettings.secondary_displays.split(",").forEach(function (sDisplay){
                record.secondary_displays.push(getField(gr, sDisplay));
            });
        }
        else
            record.secondary_displays = getField(gr, 'short_description');
       
        record.updated_on = gr.getValue('sys_updated_on');
        record.state = gr.getDisplayValue('state');
        if((recordIdx !== 0) && (data.lastLimit - limit === recordIdx))
            record.highlight = true;

        data.request.req_list.push(record);
        recordIdx++;
    }

    if (gr.next())
            data.hasMore = true;
})();

Aishwarya Shelake

this works for me.

 

Aishwarya Shelake