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

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;
}

})()

 

I will try this later on and see the result.

If it works I will mark the answer correct.

 

 

Thank You

This worked but the only issue was that the list was not in descending chronological order so I had all the old requests at the top of the list.

 

Thank you for your help though