Convert days entered into hours

Andrew Bettcher
Kilo Sage

Hello,

I have a business rule the converts a duration field (Hours, Minutes and Seconds) into a number of working days represented (based on a 7.5 hour working day):

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

	
	var time = (current.effort.dateNumericValue());
	current.u_planned_effort_days.setDisplayValue(time/(60*60*7.5*1000));
	
	// Add your code here

})(current, previous);

 

It works fine but the operators want to option to add planned effort to a project either by entering the number of hours (and having it converted and displayed) OR entering the number of days and having it converted to hours.

We need to keep the concept of hours because our workforce uses hours to record their time on time cards.

It seemed simple to reverse this BR  so that it looks like this:

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

	
	var time = (current.u_planned_effort_days);
	current.effort.setDisplayValue(time*(7.5));
	
	// Add your code here

})(current, previous);

I tried it with .dateNumericValue in place first. Didn't work and so I removed it based n the idea that the value is already numeric. This calculation should simply take whatever number is added to u_planned_effort_days and the set the value of current.effort to whatever it is multipled by 7.5.

It doesn't work.

Any ideas?

 

10 REPLIES 10

How do you want to see the value on the duration field, and what are you getting at the moment??

-Anurag

Andrew Bettcher
Kilo Sage

Hi,

The duration value (Planned Effort Hours) currently looks like this:

 

find_real_file.png

But it wouldn't make any different if it appeared in the same way as the other fields there (Actual Effort Hours).

Can you confirm the type of Actual Effort hours field, i don't think it is duration type.

-Anurag

Andrew Bettcher
Kilo Sage

Hi,

 

It is Duration. It is showing a result derived from approved time cards submitted against sub-tasks. This entire value is then subtracted from the Planned Effort and the remainder is displayed in the Remaining Effort field:

 

find_real_file.png

 

Hi Andrew,

 

I think i got it, 

This is how i see this field in my personal instance

find_real_file.png

 

Then I went in the dictionary and checked the read only flag to true

find_real_file.png

 

Now I see the field on the form as

 

find_real_file.png

 

Please mark my answer correct/helpful if it helps you solve your issue.

-Anurag

 

-Anurag