Format the duration field from another app
Hi, I have a calculation field that gets and displays the title and the time of all the selected items in the Relationship field. This is the script that I'm using :
---------------------------------------------------------------------
var alltitle = @All of Title.length;
var allsumtxt = "";
var alltime = parseFloat(@All of Time);
for (var i = 0; i < alltitle ; i++) {
allsumtxt = allsumtxt + "<br/>" + "• " + @All of Title[i] + " - " + @All of Time[i] + "";
}
---------------------------------------------------------------------
But this somehow returns the time with minutes in a strange format as shown in the screenshot below. If possible, I want to have it like: • Title - 4h. 4m.
Thanks
-
Hi Lennie,
parseFloat(@All of Time) doesn't work (you can't parse an array).
var alltitle = @All of Title;
var alltime =@All of Time;
var allsumtxt = [];
for(var i = 0; i < alltitle.length; i++){;
hour = parseInt(alltime[i]);
min = (Number(alltime[i])*60)%60;
allsumtxt.push("- " + alltitle[i] + " - " + hour + " h " + min + "m");
};
allsumtxt.join("\n")Rainer
-
Hi Rainer, the 4h 4.06666m in Test 04 seems to be correct now however, the unnecessary 1m in Test 05 is still there and also with Test 01 and Test 02. And nope, the only entry in both Test 02 and Test 05 are the hour but it shows extra m while Test 01 returns 4m instead of 15m. Please see screeenshot.
-
I just want to do the same thing, to get the Title and the Time of the second app and post it in my calculation field also in the same format as the first referenced app. • Title - 1h. 1m. But I want to do it on the same calculation field. Basically, what I'm trying to do is to create a summary of the title and time of all the items chosen in the relationship field regardless if it's from first or second app. See screenshot below, the item Test 01 is from the first app while 2nd app is from the second app, the calculation only showed • Title 01 - 4h. 15m and I want it to return as :
• Title 01 - 4h. 15m
• 2nd app - 0h. 30mThank you :)
Please sign in to leave a comment.
Comments
20 comments