Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add Column name in My Request Widget

neethu4
Giga Expert

Hi All,

I want to modify My Request widget to add Created and Updated date  along with state and number column name.

How can i add column in the script and the date format need to change ad actual date instead of days ago.

Thanks,

Neethu

1 ACCEPTED SOLUTION

Hi Neethu,

I have done the required changes in the HTML part of my new clones widget and i have attached it in this reply.

You need to do little changes in the server script also for the cloned widget as follows:

Update server side script with the two lines after line number 153:
// new code sart
record.number=gr.getValue('number');
record.created_on=gr.getValue('sys_created_on');
// new code ends

 

After doing the changes you need to replace this widget with the My Requests widget in your portal page Requests.

as shown below:

find_real_file.png

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

View solution in original post

13 REPLIES 13

Hi Mohit,

I tried the above script and it didn't add the column or column label

Thanks,

Neethu

I need to add the Column name for the existing column(Number,State,Updated On) and one new column with column name(Created On)

 

Hi Neethu,

I have done the required changes in the HTML part of my new clones widget and i have attached it in this reply.

You need to do little changes in the server script also for the cloned widget as follows:

Update server side script with the two lines after line number 153:
// new code sart
record.number=gr.getValue('number');
record.created_on=gr.getValue('sys_created_on');
// new code ends

 

After doing the changes you need to replace this widget with the My Requests widget in your portal page Requests.

as shown below:

find_real_file.png

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

For some reason not able to attach the Attachment so mentioning the code below:

<div class="panel panel-default b">
<div class="panel-heading" >
<h2 class="panel-title">{{c.options.title}}</h2>
</div>
<div class="panels-container list-group">
<div class="list-group-item row" style="margin:0px;border-top:0px;" >
<div class="col-md-5" style="">
<div class="input-group">
</div>
</div>
<div class="col-md-3 col-xs-5" style="">
<div class="form-inline" ng-if="c.options.show_view == 'true'">
<label class="control-label hidden-xs" for="view">${View}</label>
<select ng-model="c.viewFilter" id="view" class="sc-basic-select" ng-change="c.changeView()" style="width:80%">
<option value="open" selected="true">${Open}</option>
<option value="close">${Closed}</option>
</select>
</div>
</div>
<div class="col-md-4 col-xs-7" style="">
<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" type="button" ng-click="c.search()" title="${Search}" aria-label="${Search}">
<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>

<!-- new code -->
<div class="list-group-item row" style="margin:0px">
<div class="col-xs-2 padder-l-none padder-r-none main-column">${Number}</div>
<div class="col-xs-2 padder-l-none padder-r-none state-column">${State}</div>
<div class="col-xs-2 padder-l-none padder-r-none updated-column">${Created}</div>
<div class="col-xs-2 padder-l-none padder-r-none updated-column">${Updated}</div>
</div>

<!-- new code end-->
<div class="list-group-item row" ng-repeat="item in c.data.request.req_list | limitTo: c.data.lastLimit track by item.sys_id" style="margin:0px" >
<div class="col-xs-2 padder-l-none padder-r-none main-column">
<div class="primary-display">


<!--commenting this <a href="?id={{::item.url.id}}&table={{::item.url.table}}&sys_id={{::item.url.sys_id}}" sn-focus="{{::item.highlight}}"> {{::item.display_field}} </a>-->


<!--new code starts-->
<a href="?id={{::item.url.id}}&table={{::item.url.table}}&sys_id={{::item.url.sys_id}}" sn-focus="{{::item.highlight}}"> {{::item.number}} </a>
<!-- new code ends-->


</div>
<!--new code starts and commenting extra fields
<small class="text-muted">
<div ng-repeat="f in item.secondary_displays" class="secondary-display">
<span >{{::f.display_value}}</span>
</div>
</small>-->
</div>
<div class="col-xs-2 padder-l-none padder-r-none state-column">
<div class="state">
<span> {{::item.state}}</span>
</div>
</div>
<div class="col-xs-2 padder-l-none padder-r-none updated-column">
<div class="created">
<!-- <i class="fa fa-clock-o" aria-hidden="true" title="${Created}"></i>-->
<sn-time-ago timestamp="::item.created_on"/>
</div>
</div>
<div class="col-xs-2 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>
</div>
<div class="col-sm-12" ng-if="c.data.hasMore" style="padding: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...}</span>
</div>
<button class="btn btn-default btn-show-more" ng-click="c.loadMore()"> ${Show More} </button>
</div>
</div>

</div>

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi Mohit,

Yes it is working as expected now

Thanks,

Neethu