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.

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

Lol when I step back and think about it this is actually the obvious solution lol. Thanks I will try some of the other solutions just out of curiosity but I envisage I may end up doing this and Marking the answer correct

Hi Out of curiosity. 

The filter contains a Sys Id.What is this sys Id and why is it needed?

 

 

Hi there,

The sys_id (90d1921e5f510100a9ad2572f2b477fe) you see is a Dynamic Filter Options record "Me" (sys_filter_option_dynamic table). Probably you have the same sys_id on your personal developer instance 🙂

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

It is a dynamic filter (ME) and sys_id will be same in your instance.

It says Request.Requested for (is dynamic) Me

As stated I tried all options this gave me the best solution.

 

Thanks all