Add conditions to list displayed by Related List Action in Agent Workspace

Nico8
Kilo Contributor

Hi,

I've created an "Add" button for a related list in Agent Workspace that display all Locations.

However I need only to display Locations type Country.

find_real_file.png

How can I achive that?

Thanks.

 

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi Nico,

you have to create an extension point.

First enter the name of the new extension point at Action Attribute "extensionPoint"

find_real_file.png

 

Then go to module "Scripted Extension Points" and open "global.RelatedListItemCandidateFilter":

find_real_file.png

 

At related links section click on "Create Implementation" to create a Script Include which will represent the extension:

find_real_file.png

 You can name the Script Include as you like. Important are

  •  Accessible from = "All application Scopes"
  • check at line 9 for "MY_EXTENSION"
  • business logic for filtering the given records for selection

 

After opening selection dialog again you can see that the country column is prefiltered:

find_real_file.png

Kind regards
Maik

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

View solution in original post

7 REPLIES 7

In this case, each related list need different conditions.

Hi Maik i have the similar requirement but i want to display the add relation button on few tables only like incident ,case,problem.So how can i achieve this:

my extension point is as follows:

var TaskRelTaskCandidateFilter = Class.create();
TaskRelTaskCandidateFilter.prototype = {
initialize: function(tableName, parentFieldName, parentRecordSysId, referencedFieldName) {
this.tableName = tableName;
this.parentFieldName = parentFieldName;
this.parentRecordSysId = parentRecordSysId;
this.referencedFieldName = referencedFieldName;
},
getFilterQuery: function() {
var selectedRecord = new GlideRecord(this.tableName);
//selectedRecord.addEncodedQuery("this.tableName='incident'^ORthis.tableName='sc_req_item'");
selectedRecord.addQuery(this.parentFieldName, this.parentRecordSysId);
selectedRecord.query();
var result = [];
while (selectedRecord.next()) {
result.push(selectedRecord.getValue(this.referencedFieldName));
}

if (result.length)
return "sys_idNOT IN" + result.join(",");

return "";
},

handles: function(thing){
return thing == "sap_add_relation";
},

type: 'TaskRelTaskCandidateFilter'
};

Hi Maik,
This was indeed very helpful in my use case.
What we want is, certain condition to be default on form load but allow user to update/edit filters later as per need.

In the screenshot you can see the filters are empty so adding new filter just return 'No record' as the filter mentioned in script include is still being applied.

SGuha1997_0-1685633929577.png

 

Thanks,
Shubhanshu