Make Capital Budget and Operating Budget mandatory to create project in PPM

MBarrott
Mega Sage

I have a requirement where we don't want to convert a demand into a project unless the capital budget or operating budget has a value entered. 

 

I've set them to mandatory via the dictionary but from what I can see it isn't pulling that setting.

 

It looks like both get their data from the Capex and Opex budgets.

 

What is the best way to check these values and ensure at least one of them is greater than the defaulted $0.00?

 

Figured maybe check against these values within the Create Project onClick script. 

 

var capital = parseFloat(g_form.getValue('capital_budget')); // added 
var operating = parseFloat(g_form.getValue('operational_budget')); // added 
 
function convertDemandToProject() {
    if (g_form.modified) {
        return g_form.addErrorMessage(getMessage('You have not saved all your changes, save the demand record before creating project'));
    } if(g_form.getValue('type') == 'project'&& g_form.getElement("calculation_type") && !g_form.getValue('calculation_type')) {
return g_form.addErrorMessage(getMessage('Please select a project calculation type under preferences.'));
}
if(capital == 0.00 && operating == 0.00) // added
{
return g_form.addErrorMessage(getMessage('Capital budget or Operating budget must be over $0.00'));
}
1 ACCEPTED SOLUTION

The two fields do exist on dmn_demand in my instance.  the following script logic works in a UI Action I have defined on dmn_demand form named "Check Budget"

 

function checkDemandBudget() {
//	var capital = parseFloat(g_form.getValue('capital_budget')); // added 
//	var operating = parseFloat(g_form.getValue('operational_budget')); // added
	var capital = g_form.getValue('capital_budget'); // added 
	var operating = g_form.getValue('operational_budget'); // added
	var capitalValues = capital.split(';');
	var operatingValues = operating.split(';');
	var capitalVal = parseFloat(capitalValues[1]);
	var operatingVal = parseFloat(operatingValues[1]);
	var total = capitalVal + operatingVal;
	alert ("capital = " + capital + ", operating = " + operating + ", total = " + total);
}

The first two lines do not result in a number, since the two fields are defined as type: Currency.

 

Screenshot 2023-12-23 113336.png

View solution in original post

6 REPLIES 6

Saurabh Gupta
Kilo Patron
Kilo Patron

is it not working?


Thanks and Regards,

Saurabh Gupta

Clicking "Create Project" while both capital budget and operating budget were "$0.00" did not generate an error and moved to creating the project which should not happen. 

var capital = parseFloat(g_form.getValue('capital_budget')); // added 
var operating = parseFloat(g_form.getValue('operational_budget')); // added 
Above will not work as no fields with name capital_budget and operational_budget are present on demand table.

Thanks and Regards,

Saurabh Gupta

The two fields do exist on dmn_demand in my instance.  the following script logic works in a UI Action I have defined on dmn_demand form named "Check Budget"

 

function checkDemandBudget() {
//	var capital = parseFloat(g_form.getValue('capital_budget')); // added 
//	var operating = parseFloat(g_form.getValue('operational_budget')); // added
	var capital = g_form.getValue('capital_budget'); // added 
	var operating = g_form.getValue('operational_budget'); // added
	var capitalValues = capital.split(';');
	var operatingValues = operating.split(';');
	var capitalVal = parseFloat(capitalValues[1]);
	var operatingVal = parseFloat(operatingValues[1]);
	var total = capitalVal + operatingVal;
	alert ("capital = " + capital + ", operating = " + operating + ", total = " + total);
}

The first two lines do not result in a number, since the two fields are defined as type: Currency.

 

Screenshot 2023-12-23 113336.png