Comments

13 comments

  • Kent Watson

    Hi Jakob,

    Are you saying you want to update a category field to a different status/category when the date field is older than 2 month of the item creation date?  If so you will need to us Globiflow for that, its not possible via a calculation.  I would suggest you post on their forum if you have Globiflow.  If you do not have Globiflow then it may be possible to create a banner that highlights if it is older, I'm just not sure how to calculate based on the inbuilt creation date, you may need to fill in a date field as creation date (or have a flow add it if you are on a plus plan).  If you want some instructions on the latter I would be happy to help.

    Kent

    0
    Comment actions Permalink
  • Jakob Rosenfeldt

    The date field it calculates from is automatically set when the item is created via flows. 

    So some instructions would be nice :) 

    thanks 

    0
    Comment actions Permalink
  • Kent Watson

    Hi Jakob,

    As mentioned this is not going to change a status, however you can use the following to create a banner

     

    var txt = (@Date.getTime()- @Created On.getTime()) > 5270400000 ? "ALERT" : "OK"  //you can change text here
    var col = (@Date.getTime() - @Created On.getTime()) > 5270400000 ? "F10714" : "677BDE" //you can change the HTML colour codes here
    write = "![](http://dummyimage.com/" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

     

    This will set an ALERT banner if the difference in the created date is greater than 61 days (5270400000 milliseconds)

    This uses the dummyimage.com website

    0
    Comment actions Permalink
  • Jakob Rosenfeldt

    So the @date.gettime is the manual date field - right? 

    @oprettet = @created on

    var txt = (@Dato for arrangement.getTime()- @Oprettet.getTime()) > 5270400000 ? "ALERT" : "OK"
    var col = (@Dato for arrangement.getTime() - @Oprettet.getTime()) > 5270400000 ? "F10714" : "677BDE"
    write = "![](https://dummyimage.com" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

     

    However an item with the date 5/8-2016 gets the OK image. 

    Have I done somthing wrong? 

    0
    Comment actions Permalink
  • Kent Watson

    Yes @Date.getTime() is the manual date

    I think I misunderstood the order of the dates

    instead of 

    @Date.getTime() - @Created On.getTime()

    use

    @Created On.getTime() - @Date.getTime()
    0
    Comment actions Permalink
  • Jakob Rosenfeldt

    OK. Made the correction and now it seems to work, however I ger the "broken image link"-icon where it before showed "OK"

     

    var txt = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "ALERT" : "OK"
    var col = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "F10714" : "677BDE"
    write = "![](https://dummyimage.com" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

     

    0
    Comment actions Permalink
  • Kent Watson

    Hi Jakob,

    You have omitted a forward slash (/)

    You have

    "![](https://dummyimage.com" 

    when it should be

    "![](https://dummyimage.com/" 
    0
    Comment actions Permalink
  • Jakob Rosenfeldt

    brilliant! 

    Works as a charm! 

     

    Thanks a lot! 

    0
    Comment actions Permalink
  • Kent Watson

    Great news.  Enjoy!

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Guys,

    FWIW - just 2 Tips:
    1. The nicer banner/buttons you get here: dabuttonfactory.com
    2. The whole calculation can be shorter:

    61 >= moment(@date).diff(moment(@Created on),"h")/24 ? x = {"col":"F10714","text":"ALERT"} : x = {"col":"677BDE","text":"OK"};
    "![]; (https://dabuttonfactory.com/button.png?t=" + x.text + "&f=Calibri-Bold&ts=24&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=5&bgt=unicolored&bgc=" + x.col + ")"

    This is the original I got from dabutton: https://dabuttonfactory.com/button.png?t=Your+Text&f=Calibri-Bold&ts=24&tc=fff&tshs=1&tshc=000&hp=20&vp=8&c=5&bgt=unicolored&bgc=3d85c6
    Just remove "Your+Text" and the color code by the variables. If you wnat the banner wider change hp=, if higher vp=

    Rainer



    2
    Comment actions Permalink
  • Kent Watson

    Thanks @Rainer, love your work as always

    dabuttonfactory.com is terrific

    and I love the simplicity of your calc.  I'll have to do some work with moment, diff and JS objects I see

    0
    Comment actions Permalink
  • Darius

    New user here..

    Where do I actually add this code to get the alert?

    var txt = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "ALERT" : "OK"
    var col = (@Oprettet.getTime()- @Dato for arrangement.getTime()) > 5270400000 ? "F10714" : "677BDE"
    write = "![](https://dummyimage.com" + 710 + "x" + 100 + "/" + col + "/" + "000000" + ".png&text=" + txt.toUpperCase() + ")"

    Thanks

    0
    Comment actions Permalink
  • Kent Watson

    Hi @Darius,

    Add it to a calculation field.  For the @date and @created on you will need to type these into the calculation field to pick up the values from your app fields. 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk