Add Watch List members of request to My requests

Joe Taylor
Giga Guru

I have added a List Collector variable to a Catalog requested item.

My notification now correctly send an email to the request and the people on this Watch list.

 

Also, the requester can see this item in his "My Requests" lists on the Portal.

 

How can I also include this requested item in the "My Requests" list for the people in the Watch List?

1 ACCEPTED SOLUTION

I figured this out.  We were making this way too difficult I think.

All I had to do was to add 1 condition to theOOB Request filter called "Service Catalog Requested Item Portal".

See screenshot.

 

JoeTaylor_0-1671565792615.png

 

Thanks again for your help.

View solution in original post

11 REPLIES 11

Kristen Ankeny
Kilo Sage

Are you copying the list of people from the variable to the watch_list on the created requested item? If so, then you should be able to update the filter on the module to include a "watch_list" contains "me".

What "module" are you referring to?

Ah, I missed the "Portal" bit. You should instead be able to create a copy of the out-of-the-box My Requests widget, change the code in the server section to query records where the person in the watch list, and then replace the oob one in the portal config with your custom copy.

Joe Taylor
Giga Guru

Kristen, I think you have hit on exactly the right approach.

I'm not exactly sure what to modify on here though.

 

Here's what my OOB "My Requests" widet Server Script looks like.

 

(function() {
if (!options.maximum_entries)
options.maximum_entries = 20;
var gr = new GlideRecordSecure('sc_request'); // does ACL checking for us
gr.addActiveQuery();
options.title = options.title || gr.getPlural();
data.display_field = 'sys_created_on';
data.secondary_fields = ['number','sys_updated_on'];
data.filterMsg = gs.getMessage("Filter...");

gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');
gr.orderByDesc('sys_created_on');
gr.query();
data.count = gr.getRowCount();
data.list = [];
var recordIdx = 0;
while (gr.next()) {
if (recordIdx == options.maximum_entries)
break;

var record = {};
record.sys_id = gr.getValue('sys_id');
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", gr.getUniqueValue());
ritm.query();
if (ritm.getRowCount() == 0)
continue;

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

record.secondary_fields = [];
data.secondary_fields.forEach(function(f) {
record.secondary_fields.push(getField(gr, f));
});

record.url = {id: 'sc_request', table: 'sc_request', sys_id: record.sys_id};
data.list.push(record);
recordIdx++;
}

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

})()