Filtering costplans

VSN
Tera Expert

I had a requirement to add filter conditions in cost plan related  list on Project, if we are in FY2024 then we need to show  start fiscal year is FY2024.example 

1.we are in FY2025(ex:2024/oct/01 to 2025/sep/31) then need to display  start fiscal year is FY2025 records,

2. if we are in FY2026(ex:2025/oct/01 to 2026/sep/31) then need to display start fiscal year is FY2026records,

i need this process for every year 

we need to do automat this process. may i know how to achive this..

 

thanks in advance 

1 REPLY 1

Anand Kumar P
Giga Patron
Giga Patron

Hi @VSN,

You have to write before query business rule in pm_project table and change field names and table names as per your requirements.

(function executeRule(current, previous) {
var nowdate= new GlideDate();//current year
var currentYear = parseInt(nowdate.getYear());
var currentMonth = parseInt(nowdate.getMonth());

var fiscalYear = currentYear;

if (currentMonth >= 4){//checking if we are in next financial year based on month
fiscalYear = currentYear + 1;
}

current.addQuery('cost_plan.start_fiscal_year', '=', 'FY' + fiscalYear);//replace cost plan with you related list 
})(current, previous);

Thanks,

Anand