- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 05:16 AM
Hi Admin Community,
I'm not an expert in Angular JS nor even JS, but I have a long background of learning on the fly and adapting to anything that comes my way as an IT professional. My post here is both one of a question about my configuration as well as I'm open to adjusting my approach.
I'm trying to achieve displaying the SC task information into the standard ticket tab by using the custom tab type as mentioned here - https://docs.servicenow.com/bundle/rome-servicenow-platform/page/build/service-portal/task/configure-st-page.html. See below.
Here is a snippet of the HTML that is showing this (which is also part of the widget I mention below):
iv>
<div role="row" class="list-group-item table-responsive" ng-repeat="item in c.data.request.req_list" style="margin:0px" >
<div role="cell" class="col-xs-2 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}}"> {{::item.display_field}} </a>
</div>
<small class="text-muted">
<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-4 padder-l-none padder-r-none shortdescription-column">
<div class="state">
<span>{{::item.shortdescription}}</span>
</div>
</div>
<div role="cell" class="col-xs-2 padder-l-none padder-r-none state-column">
<div class="state">
<span>{{::item.state}}</span>
</div>
</div>
<div role="cell" class="col-xs-2 padder-l-none padder-r-none created-column">
<div class="created">
<i class="fa fa-clock-o" aria-hidden="true" title="${Created}"></i>
<sn-time-ago timestamp="::item.created"/>
</div>
</div>
<div role="cell" 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>
The widget that I'm embedding in the tab area is the My Request widget. I like the use of it since it gives me the ability to adjust the information presented using both scripting (if desired) as well as the Standard Ticket Configuration on the backend. So, it's very versatile for me at the moment while I continue to learn JS and AngularJS as one of the admins of this tool. The widget screenshot as well is just a dump (with a display limiter on it) of all SC task information related to myself (ie My Requests).
I know that you cannot call the parent.sys_id of the SC task here just by using the current instance of the serverside scripting since the code is isolated in the widget itself. However, I do know that you can use a scope call to bring in the current sys_id of the RITM and hold that as a variable. What I don't know is below, and I'm hoping someone can either help me or guide me in the right direction here.
- Do I control the while loop of gr.next() with a condition (scoped sys_id) on the Serverside script of the widget?
- Do I control the NG-Repeat of the HTML with a condition (scoped sys_id or anything else) on the Angular side of the HTML portion of the widget?
- Should I take another direction with a condition to display this information?
Again, I'm open to feedback on this and want to understand what is correct in my assumption and what clearly is not.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 06:59 AM
Hi all,
I have definitely solved my initial request to gain only related SC tasks to the RITM using the suggested direction from
This is very specific to a widget embedded inside another widget where calling the parent sys_id is NULL by default and design.
Steps
Variable Work
I had to ensure the scoped RITM sys_id for the instance was stored in a variable.
var sys_id = (input && input.sys_id) || options.sys_id || $sp.getParameter("sys_id");
var sysId = options.sys_id || $sp.getParameter('sys_id');
Serverside Scripting
What I had to do was leave the original taskIDs alone in the "My Requests" widget and actually add another line as Palani may have hinted beforehand.
gr.addQuery('parent.sys_id=' + sysId);
This isolated (when specifically filtering out SC tasks) related records of the parent sys_id using the scoped values in the variable.
Caveats
Users by default do not have privilege to access and read/write to the sc_task table via roles. I will have to research how to enable that by ACL to role if ServiceNow allows that.
Hopefully this helps a lone soul like myself who isn't a developer by trade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 10:21 AM
i also have the same requirement, can some help me with the code widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 12:09 AM
Hi Adam,
I have the similar requirement where I need to display Related Tasks of RITM in Tab configuration.
Could you please provide me the widget code and Tab configuration screenshot that will be helpful for me.
Thanks in advance.