We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

BR to require Cost plan is not aborting

lbless1
Giga Expert

I have a requirement that a cost plan must be created before Screening. I have created a BR but it is not aborting.

 

I have the trigger set to:

lbless1_1-1771366597887.png

 

 

 

(function executeRule(current, previous /*null when async*/) {

// Only enforce when transitioning into Screening
if (current.state == '3' && previous.state != '3') {

var cp = new GlideRecord('cost_plan');
cp.addQuery('task', current.sys_id);
cp.setLimit(1);
cp.query();

if (!cp.hasNext()) {
gs.addErrorMessage('A Cost Plan must be created before moving the Demand to Screening.');
current.setAbortAction(true);
}
}

})(current, previous);

 

3 REPLIES 3

sanketpatil09
Tera Guru

You can enforce this by preventing Screening unless a Cost Plan exists. The simplest way is to use a Business Rule or Flow that checks for a Cost Plan record and blocks the Screening action with a message if it’s missing, or hide/disable the Screening option using a UI Policy until the Cost Plan is created.

Namita Mishra
ServiceNow Employee

Happy Monday @Giga Expert !!

Typically the organizations do the detailed cost planning after screening. This is because screening is intended to be a lightweight, quick evaluation to filter the demands before investing significant effort in detailed planning.

However, in your organization's case, it seems that stakeholders would like to 

 

  • have more informed screening decisions with cost data available
  • see the cost upfront during evaluation so they can consider the cost as well while screening the demand. This will help them approving only those demands that can be afforded within the given budget.

Consider SPW -> Financials where you can see all the investments including the demands. If the cost is visible, it would help the stakeholders in approving the future demands.

 

I would suggest you to understand the requirement to take a better decision. This would help you in deciding whether they really are asking about the cost plans or they would like to see high level cost just in terms of Capex and Opex for unapproved demands. This would help the stakeholders to take approval decision based on the funding.

Later for the approved ones you can do the detailed cost plans. 

 

Hope this helps & if it does please mark this as a correct response to help me and other community members.

 

Have a Great SPM Journey!!

 

Thank You!

Namita Mishra

 

Tanushree Maiti
Giga Sage

It can be achieved by BR. when state will change to Screening , it will check whether cost plan is in place or not (using Br's advance script)

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