Format the duration field from another app

Comments

20 comments

  • Rainer Grabowski

    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

    1
    Comment actions Permalink
  • Lennie

    Hello Rainer,

    Almost there, it's just that the duration doesn't get the correct value. As per screenshot below, Test 04 has 4h 4m but in the calc it shows 4h 4.06666m while Test 05 only has 1h. but shows as 1h 1m.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Round the minutes:

    allsumtxt.push("- " + alltitle[i] + " - " + hour + " h " + Math.round(min) + "m")

    1m in Test 5 is strange - if in the duration field the only entry is 1 in hours. Any seconds or min. in it?

    Rainer

    0
    Comment actions Permalink
  • Gus H.

    Hi Rainer. I'm getting a "Unexpected token" error too. :-( .

    0
    Comment actions Permalink
  • Rainer Grabowski

    This line must end with a curly bracket:

    for(var i = 0; i  < alltitle.length; i++){;
    0
    Comment actions Permalink
  • Gus H.

    Thanks Rainer. Still no luck.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Those damned typos :(
    Last line must be:

    allsumtxt.join("\n")

     

     

    0
    Comment actions Permalink
  • Lennie

    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.

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Lennie, please share a screenshot of your calculation.

    0
    Comment actions Permalink
  • Lennie

    Here ya go. Thank you Rainer :)

    0
    Comment actions Permalink
  • Rainer Grabowski

    See my calculation above:

    min = (Number(alltime[i])*60)%60;

     

    1
    Comment actions Permalink
  • Lennie

    It worked! Thank you so much Rainer :D

    0
    Comment actions Permalink
  • Gus H.

    Thank you Rainer. 

    0
    Comment actions Permalink
  • Lennie

    Hello again Rainer,

    Just got an extra question for this one. What if the Relationship field is referenced to two apps?
    Sorry for the trouble, thank you.

    0
    Comment actions Permalink
  • Rainer Grabowski

    As long as you pick the right @all of - field token everything is ok. 

    0
    Comment actions Permalink
  • Lennie

    Hi Rainer,

    How can I insert the other @all of of the second referenced app? Right now, it only gets the @all of title and @all of time of the first app but when I selected an item coming from the second app, the Summary field returns nothing. I hope I make sense.

    Thank you.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Depends on what you want to do with the other @all of of the second referenced app. Can you explain and/or send a screenshot?

    0
    Comment actions Permalink
  • Lennie

    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. 30m

    Thank you :)

    0
    Comment actions Permalink
  • Rainer Grabowski

    You simply have to concatenate the arrays.

    var alltitle = @All of Title app1.concat(@All of Title app2,@All of Title app3);
    var alltime = @All of Time app1.concat(@All of Time app2,@All of Time app3)
    1
    Comment actions Permalink
  • Lennie

    Thanks Rainer, legend!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk