Using “If” or “Else” and Combining Fields

25 views
Skip to first unread message

Randy Flinn

unread,
Jun 25, 2026, 5:24:32 PM (3 days ago) Jun 25
to Vasily from Memento, mementodatabase
I have a field named “Title” and another named “PurchDate”.  “Title” may or may not have data entered.  I wanted to created a JavaScript field that combines the two fields with a format of (which I did):

Title - PurchDate

However, if Title is empty, null, etc., I only want the PurchDate value (without the “-“).

PurchDate

I have tried to use a JS to determine if Title is empty with no success.  Any assistance would be appreciated.

Mmm

unread,
Jun 25, 2026, 11:58:51 PM (3 days ago) Jun 25
to mementodatabase
Вариант для поля JS (необходимо подключить moment.min.js):

let title = field("title");
let date = field("PurchDate");
let date_str = date ? moment(date).format('DD.MM.YYYY') : date;

if (title && date) 
    title.trim() + ' - ' + date_str;
else if (title)
    title;
else if (date)
    date_str;
else
    'No data';

пятница, 26 июня 2026 г. в 00:24:32 UTC+3, rfli...@gmail.com:
Reply all
Reply to author
Forward
0 new messages