How to create Entity filter using Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2023 03:05 AM
Hello,
can someone please help me to setup Entity filter using a Script include?
I'm trying to create an entity filter for Project table (pm_project) based on values from Project task table (pm_project_task) related to the Project. Values are 'Short Description' and 'State'. Because it cannot be done using filter condition as I cannot dot walk from pm_project to pm_project_task, I have to create script include to call the script from the filter condition.
Can anyone please help me with the script include and what should be used in the Entity filter condition to get a result?
Herebelow is what I have created so far, but it doesn't work (to be honest, I'm not really good in scripting).
The Script include is 'Client callable'.
var FilterTG3ProjectTask = Class.create();
FilterTG3ProjectTask.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getProjectTaks: function() {
var taskIdArray = [];
var tgTask = new GlideRecord('pm_project_task');
tgTask.addEncodedQuery('short_description=TG 3^state=3');
tgTask.query();
while (tgTask.next()) {
taskIdArray.push(tgTask.getValue('sys_id'));
}
return 'sys_idIN' + taskIdArray.join();
},
type: 'FilterTG3ProjectTask'
});
Thank you for any help in advance!
Gabriela
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2023 03:40 AM
I haven't worked with entities yet.
But if you're calling via ajax, can you include a screenshot of how you're calling this script include? The encoded query will report every pm_project_task with those conditions unrelated to what it's parent is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 05:20 AM
Hi,
thank you for your reply. Yes, you're right, this is a mistake, I didn't want to call it via ajax, so I've did some correction and it works now.