Free Support Forum - aspose.com

Get CPI and SPI is not working

Hello team. I’m succeeding in capturing
tsk.get (Tsk.BCWS) and
tsk.get (Tsk.BCWP)

but the api is not working when I use it
tsk.get (Tsk.CPI)
tsk.get (Tsk.SPI)

despite the documentation on the link below, a message is displayed stating that the option does not exist

https://apireference.aspose.com/tasks/java/com.aspose.tasks/Field#TaskCPI

or…do you have any code example to capture these 2 values? I didn’t find

Could you help me please?

Thank you very much

@construtivo

Can you please elaborate the issue in the form of source file and working sample code that you are using and which is failing on your end.

We have a 12 hour time difference, that is, each of our interactions, we always lose a day.

Well, follow the part of the code where I mark the two lines that are not working because it gives an error. It is as if the CPI and SPI options did not exist

	Project project = new Project(filePath);
	ChildTasksCollector collector = new ChildTasksCollector();
	TaskUtils.apply(project.getRootTask(), collector, 0);
	List tasks = collector.getTasks();
	int iSize = tasks.size();
	for (int i = 0; i < iSize; i++) {
		Task tsk = (Task) tasks.get(i);
		JSONObject jo = new JSONObject();
		jo.put("Id", tsk.get(Tsk.ID));
		jo.put("Uid", tsk.get(Tsk.UID));
		jo.put("Name", tsk.get(Tsk.NAME));
		jo.put("bcws",tsk.get(Tsk.BCWS).toString());
		jo.put("bcwp",tsk.get(Tsk.BCWP).toString());

		jo.put("cpi",tsk.get(Tsk.CPI).toString());  // <<<<<<< this is not working
		jo.put("spi",tsk.get(Tsk.SPI).toString());  // <<<<<<< this is not working

@construtivo

We are sorry for your inconvenience. I have added a ticket with ID TASKSJAVA-1300 as we need to investigate this further and will get back to you with feedback as soon as it will be shared.

@construtivo

We don’t have exposed API for CPI and SPI at this moment. However, you can easily calculate these values by yourself using following formula.

CPI = BCWP / ACWP
SPI = BCWP / BCWS

ACWP, BCWP and BCWS are all accessible using task.get(Tsk.ACWP) and so on.

great suggestion, thank you very much. And I’m sorry if I looked impatient. My bad.

@construtivo

You are always welcome.