Logic in the Custome column

Hello,

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?
Thanks,

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;
    else
      result = false;
  
    return result;
  })()
}}
2 Likes

It works well. Thanks,

1 Like