Display the RITM instead of REQ Number in a copy of the Request Item Portal Widget

Markell
Tera Guru

Hi Guys

What I am trying to do seemed easy but so far no real idea as Angular is like Klingon to me.

Basically, All I want to do is on a copy of the Request Item Widget Instead of displaying REQ Number:

find_real_file.png

 

I want to display the actual RITM

find_real_file.png

I thought of dot walking to it but in the script of the widget it is using some different methods that I am not familiar with

 

See below

find_real_file.png

find_real_file.png

find_real_file.png

I am guessing that the value of Function "Getfield" (Line 46 of the ServerSide script) called name is passed to the Html "f.title" and/ or "f.Label". 

 

I have tried manipulating this but do not get any luck.

 

Can anyone direct me with this or tell me how to point to the "number" column of the "sc_request_item" table?

 

 

Kind Regards

 

 

 

Markell

1 ACCEPTED SOLUTION

Surendra Poosa1
Kilo Expert

Hi Markell,

We had a similar requirement recently. I ended up making a copy of the widget and updating the server script to the following.

 

(function() {

var gr = new GlideRecordSecure('sc_request'); // does ACL checking for us
gr.addQuery('active',false);
options.title = options.title || gr.getPlural();
data.display_field = 'sys_created_on';
data.secondary_fields = ['number','sys_updated_on','short_description'];
data.filterMsg = gs.getMessage("Filter...");
data.count = gr1.getRowCount();
data.list = [];
gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');
gr.orderByDesc('sys_created_on');
gr.query();



while(gr.next())
{
var gr1 = new GlideRecord("sc_req_item");
gr1.addQuery("request", gr.getUniqueValue());
gr1.query();

var recordIdx = 0;
var record = {};

while(gr1.next())
{
if (recordIdx == options.maximum_entries)
break;

record.sys_id = gr1.getValue('sys_id');

if (gr1.getRowCount() == 0)
continue;

if (gr1.getRowCount() > 1)
record.display_field = gs.getMessage("{0} requested items", gr1.getRowCount());
else
{
gr1.next();
record.display_field = gr1.cat_item.getDisplayValue() || gr1.getDisplayValue("short_description");
}

recordIdx++;



record.secondary_fields = [];
data.secondary_fields.forEach(function(f)
{
if(f=='short_description')
record.secondary_fields.push(getField(gr, f))
else
record.secondary_fields.push(getField(gr1, f))
});

record.url = {id: 'ticket', table: 'sc_req_item', sys_id: record.sys_id};
data.list.push(record);
}

}

function getField(gr, name) {
var f = {};
f.display_value = gr.getDisplayValue(name);
f.value = gr.getValue(name);

var ge = gr.getElement(name);
f.type = ge.getED().getInternalType();
f.label = ge.getLabel();
return f;
}

})()

 

View solution in original post

12 REPLIES 12

rajesh9885
Mega Guru

You are right

You need to make change from line 46

gr. return requests and ritm. returns requested item(ritm)

I wll try this to see what happens later today thank you for your response 🙂

Alikutty A
Tera Sage

Hi Markell,

The My Requests widget is querying on the sc_request table and it return list of request records. You can access the RITM by customizing it but then it cannot be rendered properly as a request can have multiple RITMs and this makes the rendering complicated.

There is another OOB widget named "Requested Items" which is best suited for your use case. Please add it on your page and explore it.

Here is its URL: https://INSTANCE_NAME.service-now.com/nav_to.do?uri=sp_widget.do?sys_id=624afdb3d7230200a9addd173e24d4f4

Replace instance name with yours.

Thanks!

Alikutty A
Tera Sage

Hi Markell,

Why dont you use a Simple List widget on the sc_req_item instead of customizing the My Requests widget. Customizing the latter to render requested items is not a simple task.

Here is an instance of simple list widget i created. You can create a similar one and add it on your page instead of using the My Requests widget,

find_real_file.png

 

Filter: 

request.requested_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe

Result:

find_real_file.png

 

Simple List widget: https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/concept/sim...