Expand my Community achievements bar.

SOLVED

how to use if statement

Avatar

Former Community Member

I am trying to Date2Num but only wnat to display the Date2Num greater than 30 days, because i am going to use that to multiply other numericfields.

with help of some genius I have come up with the NumOfdays formula but need the if statement. thanks

NumOfDays=Date2Num(endDate.rawValue,"YYYY-MM-DD")- Date2Num(startDate.rawValue,"YYYY-MM-DD")

Var  NumOfDays = event.target;

If (NumOfDays> 30) then

NumOfDays = NumOfDays - 30

NumOfDays.textColor = color.red;

else

NumOfDays = “ “

NumOfDays.textColor = color.black;

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Here's my FormCalc version.

var numOfDays = Date2Num(endDate.rawValue,"YYYY-MM-DD") - Date2Num(startDate.rawValue,"YYYY-MM-DD")

if (numOfDays > 30) then

  NumOfDays.rawValue = numOfDays - 30

  xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,0,0"

else

  NumOfDays.rawValue = null

  xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,255,255"

endif

Steve

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

Here's my FormCalc version.

var numOfDays = Date2Num(endDate.rawValue,"YYYY-MM-DD") - Date2Num(startDate.rawValue,"YYYY-MM-DD")

if (numOfDays > 30) then

  NumOfDays.rawValue = numOfDays - 30

  xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,0,0"

else

  NumOfDays.rawValue = null

  xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,255,255"

endif

Steve

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----