Logic in the Custome column


I created new custom column (NowSubscription) in my table as you see below screenshot and wanted to add logic in value under content.

My logic should be that it returns "true" when start_date is not null and start_date is before today and I tried several ways but it doesn't work.
Could you please help me how to fix it?

Hey @tax,

Some fields only allow JavaScript expressions and not statements.

You could either use a ternary operator, which being simple is the best choice for this use case

{{ (currentSourceRow.start_date !== null && moment(currentSourceRow.start_date).isBefore(moment())) ? true : false }}

or you could use an IIFE, which is a better, more readable choice for logic too complex to be expression(ed).

    var result;
    if (currentSourceRow.start_date !== null && moment(currentSourceRow.start_date).isBefore(moment()))
      result = true;
      result = false;
    return result;

It works well. Thanks,

1 Like