Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to configure the default filter in cases related list in csm workspace on case form

ss52
Tera Contributor

Hi All,

 

We have a requirement to configure default filter on cases related list on case form IN CSM Workspace when we click on Add button. It should similar cases based on current short description. Please find the attached screenshot.

 

Kindly assist on this.

 

 
 

 

3 REPLIES 3

Tanushree Maiti
Tera Sage

Hi @ss52 

 

Check these article, posts:

Step by step instruction is given.

https://www.servicenow.com/community/service-operations-workspace/how-to-setup-a-default-filter-for-...

 

https://www.servicenow.com/community/developer-forum/how-to-add-default-filters-for-related-records-...

 

https://www.servicenow.com/community/itsm-forum/agent-workspace-how-to-set-default-filter-on-related...

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Shruti
Giga Sage

Hi @ss52 

1.Navigate to sys_extension_instance.LIST

2.Create a new record

Point -> global.RelatedListItemCandidateFilter

Class - Create a new class with Name = > CSMRelatedListCaseFilter . 

 

3.Paste below code to the script include "CSMRelatedListCaseFilter"

var CSMRelatedListCaseFilter = Class.create();
CSMRelatedListCaseFilter.prototype = {

    initialize: function(tableName, parentFieldName, parentRecordSysId, referencedFieldName) {
        this.tableName = tableName;
        this.parentFieldName = parentFieldName;
        this.parentRecordSysId = parentRecordSysId;
        this.referencedFieldName = referencedFieldName;
    },

    getFilterQuery: function() {
        var result = [];
        var gr = new GlideRecord(this.tableName);

        if (gr.get(this.parentRecordSysId) && !gr.short_description.nil()) {
            var gr1 = new GlideRecord(this.tableName);

            gr1.addQuery('short_description', 'CONTAINS', gr.getValue('short_description'));
            gr1.addQuery('sys_id', '!=', gr.getUniqueValue());
            gr1.addActiveQuery();
            gr1.query();

            while (gr1.next()) {
                result.push(gr1.getUniqueValue());
            }
        }


        return "sys_idIN" + result.join(",");
    },

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

    type: 'CSMRelatedListCaseFilter'
};

4. Navigate to Now experience framework -> Related List actions

5. Open Add button on case table. Check attached screenshot

6. Open Specify client action -> Add Related Item Requested 

7.  Go to the payload and update extension point to  "extensionPoint": "CHILD_CASE_QUERY_FILTER"

 

 

 

 

 

Ankur Bawiskar
Tera Patron

@ss52 

did you check the Related list actions? either of these somewhere you can add that filter

55.png

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader