UI Only Field DateTime Calculation

  • 1
  • Question
  • Updated 1 year ago
  • In Progress
So I've seen that UI only fields cannot do calculations on DateTime fields, just Dates using formulas like this post https://community.skuid.com/skuid/topics/calculate-age-with-ui-only-field

Has anyone figured a relatively easy method/hack to do this aside from creating formula fields in Salesforce? We want to subtract 1 hour from a Salesforce DateTime field in the Skuid UI.
Photo of ddeveaux

ddeveaux

  • 1,202 Points 1k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
ui formula fields can use datetime fields. They are just expressed in milliseconds.

So to subtract an hour, you want

{{Datetime__c}} - (1000*60*60)
Photo of ddeveaux

ddeveaux

  • 1,202 Points 1k badge 2x thumb
This thread from a bit back seems to confirm. Actually even the dates may not work I might have been mistaken.

https://community.skuid.com/skuid/topics/ui-only-formula-fields-add-1-month-to-date
Photo of ddeveaux

ddeveaux

  • 1,202 Points 1k badge 2x thumb
I had thought so too but tried that many times in past and doesn't display. The calculation seemed to work off Date fields to subtract a day but not DateTime. Just tried it now and still get blank. The DateTime field is in the model.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
What do you get if you change the displaytype of the formula field to Text?
Photo of ddeveaux

ddeveaux

  • 1,202 Points 1k badge 2x thumb
Zip. Output blank so far for Text, Date, DateTime.

But after I saw JDs respons that said this isn't supported I stopped playing with it esp since seems like would be straightforward if it did work. If I remove the calculation it does display as a DateTime.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
That's so strange. Well, you can do it with a javascript snippet.
Photo of ddeveaux

ddeveaux

  • 1,202 Points 1k badge 2x thumb
Yeah, not super versed in those so try to avoid if can but don't we now have to put those as static resources also? I'm only passively following the changes in Salesforce but thought that was one of the big things at least coming, even if I get away with it for today.