Format Date through Relationship
I am trying to format a date using moment.js. What I would like to use is moment(@all of date).format('L') or something similar in after the .format where I can pluck out what I need to pluck out the GMT time, Year etc. I always get an invalid date response when I use this method, HOWEVER, if I create two fields and in the first field use @all of date.join() and in another field use moment(@date).format('L) the moment.js scripting works fine. Basically, I am using this to build a report for later, and the date field will sometimes be empty, and I'd just rather have the field be empty instead of saying "invalid date". I think this would work fine, if I could condense this method down to one field instead of the two like it is now. Any ideas?

  • Hi Nathan, you could use moment(@all of date.toString()).format('L') if there is only one item referenced. If there a more items referenced you'll get "Invalid Date" in the target item. With .toString you don't need the var DATE COPY (I would prefer the version like you use now: var date copy = @all of date ... ) If you want to avoid "Invalid Date" to be shown in case the date field of the referenced item is empty you can use @all of date != "" ? moment(@all of date.toString()).format('L') : null Rainer
  • In the Referenced App it looks like this now: DATE COPY - @all of date.join() with the result as the full date with GMT time stamp and DATE FOR REPORT - moment(@DATE COPY).format('L') which will format it as needed. I need to just have one field that does it all, and its odd that using moment.js works this way, but not directly referencing the date from the other app.
This question is closed.