- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2022 07:44 AM - edited 12-26-2022 03:34 AM
In the pm_project related lists expense lines, and cost plans are there
On fm_expense_line record, there is 'cost plan' and 'task' reference fields
Generally cost plan field shows all cost plans.
If we take New expense line from pm_project related list, then task field is shown that project number like PRJ0002345. then Cost plans should show only related to PRJ0002345, if this was child project then show parent project cost plans
If it is Project task then it show parent Project costplans
if task field is empty or any other . So now we need all cost plans in that cost plan field.
I tried script include for reference qualifier, its not working please correct this
var CostPlanScriptInclude = Class.create();
CostPlanScriptInclude.prototype = {
initialize: function() {
},
getCostPlanReferenceQualifier: function(task) {
if (task.sys_class_name == 'pm_project' || task.sys_class_name == 'pm_project_task') {
return 'sub_tree_root=' + task;
} else {
return '';
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 02:16 AM
Hey Venkat,
I have added the required scripts in your instance. It's working as expectation.
I have used cost_plan, task. I have added the condition for pm_project, you can expand it as per your need.
Script Include:
var testdynamicfilter = Class.create();
testdynamicfilter.prototype = {
initialize: function() {},
refqual: function() {
var container = [];
var GrpU = current.task.number; // Task number we select on form
var classType = current.task.sys_class_name; // type of the task
// gs.info(" Number: "+ GrpU + "class:" + classType );
var testing; // variable to convert the glide to tostring
if(classType=="pm_project") // it will give only the related records if type = pm_project
{
var grpMember = new GlideRecord('cost_plan');
grpMember.addQuery('task.number', GrpU);
grpMember.query();
while (grpMember.next()) {
testing = grpMember.sys_id;
container.push(testing.toString());
//gs.info("toope " + grpMember.sys_id);
}
//gs.info("usermember: " + container.toString());
return 'sys_idIN' + container.toString();
}
else {
return 'all';
}
},
type: 'testdynamicfilter'
};
Dictionary Entry:
Result:
When task is empty or class type not pm_project, all records.
Else, it will display cost plans on the basis of tasks
Please mark this solution as correct and helpful. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 02:16 AM
Hey Venkat,
I have added the required scripts in your instance. It's working as expectation.
I have used cost_plan, task. I have added the condition for pm_project, you can expand it as per your need.
Script Include:
var testdynamicfilter = Class.create();
testdynamicfilter.prototype = {
initialize: function() {},
refqual: function() {
var container = [];
var GrpU = current.task.number; // Task number we select on form
var classType = current.task.sys_class_name; // type of the task
// gs.info(" Number: "+ GrpU + "class:" + classType );
var testing; // variable to convert the glide to tostring
if(classType=="pm_project") // it will give only the related records if type = pm_project
{
var grpMember = new GlideRecord('cost_plan');
grpMember.addQuery('task.number', GrpU);
grpMember.query();
while (grpMember.next()) {
testing = grpMember.sys_id;
container.push(testing.toString());
//gs.info("toope " + grpMember.sys_id);
}
//gs.info("usermember: " + container.toString());
return 'sys_idIN' + container.toString();
}
else {
return 'all';
}
},
type: 'testdynamicfilter'
};
Dictionary Entry:
Result:
When task is empty or class type not pm_project, all records.
Else, it will display cost plans on the basis of tasks
Please mark this solution as correct and helpful. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 02:47 AM - edited 12-27-2022 02:49 AM
Wowww Thankyou you very much @Taha Habib. I'm appreciating your Patience, hard work and logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2022 03:09 AM
Thanks for the appreciation Venkat.