Turn Duration field into Text by using Calculation field

markdown11.8

 

How can you take information from a Duration field? If you put it in a Calculation field simply as @Duration, it is shown as a number, which can be a problem.

The best way to turn a Duration field into Text field is done by the following Javascript code. It will then show exactly what is shown in Duration field. Just copy paste the following code to a Calculation field:

 

var df = @Duration;
var h = Math.floor(df);
var m ;
var s ;

var r = df – h; r *= 600000; r = Math.round(r); r/= 10000; 
m = Math.round(r);
s = r – m; s *= 60000; s/= 1000; s = Math.round(s);

((h > 0) ? h.toString() + ” hour” : “”)       + 
((h == 1) ? ” ” : (h > 0)? “s ” : “”)           + 
((m > 0) ? m.toString() + ” minute” : “”)  + 
((m == 1) ? ” ” : (m > 0)? “s ” : “”)         + 
((s > 0) ? s.toString() + ” second”  : “”)  +
((s == 1) ? ” ” : (s > 0)? “s ” : “”) 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

Make sure you only replace the @Duration with your app’s Duration field. Thus, the following changes in “Modify Template”:

markdown11.1

give us the following result:

markdown11.2

 

—————————————————————————————————————————

If you prefer to have all hours, minutes and seconds shown in a Text field, so there are no hidden values in case of a zero. This is possible. Just copy paste the following code to a Calculation field:

var df = @Duration;

var h = Math.floor(df);
var m ;
var s ;

var r = df – h; r *= 600000; r = Math.round(r); r/= 10000; 
m = Math.round(r);
s = r – m; s *= 60000; s/= 1000; s = Math.round(s);

h.toString() + ” hour”      +
((h == 1) ? ” ” : “s “)       + 
m.toString() + ” minute”  + 
((m == 1) ? ” ” : “s “)      +
s.toString() + ” second”  +
((s == 1) ? ” ” : “s “)

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

Make sure you only replace the @Duration with your app’s Duration field. Thus, the following changes in “Modify Template”:

markdown11.3

give us the following result:

markdown11.4

 

 

Do you want to show Duration in a short way? Just copy paste the following code to a Calculation field:

var df = @Duration;
var h = Math.floor(df);
var m ;
var s ;

var r = df – h; r *= 600000; r = Math.round(r); r/= 10000; 
m = Math.round(r);
s = r – m; s *= 60000; s/= 1000; s = Math.round(s);

((h > 0) ? h.toString() + “h ” : “”)    + 
((m > 0) ? m.toString() + “m ” : “”) + 
((s > 0) ? s.toString() + “s”  : “”) 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

Make sure you only replace the @Duration with your app’s Duration field. Thus, the following changes in “Modify Template”:

markdown11.5

give us the following result:

markdown11.6

 

If you want to show Duration in a short way, but with hours, minutes and seconds shown at the same time, just copy paste the following code to a Calculation field:

 

var df = @Duration;
var h = Math.floor(df);
var m ;
var s ;

var r = df – h; r *= 600000; r = Math.round(r); r/= 10000; 
m = Math.round(r);
s = r – m; s *= 60000; s/= 1000; s = Math.round(s);

h.toString() + “h ”   + 
m.toString() + “m ” + 
s.toString() + “s” 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

 

Make sure you only replace the @Duration with your app’s Duration field. Thus, the following changes in “Modify Template”:

markdown11.7

give us the following result:

markdown11.8

No comments yet.

Leave a Reply