Hello everyone ! I’m using the following formula t...
# suiteflow
l
Hello everyone ! I’m using the following formula to setup a date in a "After Field Edit" scenario, and it works fine:
Copy code
nlapiDateToString(nlapiAddDays(nlapiStringToDate({custbody5}),-3))
I wanted to do the same, but set it to -5 when the day is monday, tuesday or wednesday, to cover the weekends, without success. I thought about using a case when, with the value of :
nlapiStringToDate({custbody5}).getDay()
That returns an integer (0 to 6) When I try to use a CASE WHEN, I get the following response from the browser’s console:
caught SyntaxError: missing ) after argument list (at salesord.nl?id=247153&whence=&e=T:13954:50)
When using case when, I get the following:
caught SyntaxError: Unexpected token 'case' (at salesord.nl?id=247153&whence=&e=T:13954:50)
So my question is, is there a way to have a conditional value, depending on the day of the week in Suiteflow ?
Just managed to do it with two actions instead of 1, and conditional execution for each:
nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() == 1 || nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() == 2 || nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() == 3
I apply the date -5 days
And nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() != 1 || nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() != 2 || nlapiStringToDate(nlapiGetFieldValue('custbody5')).getDay() != 3
I apply the date -3 days
n
This is a formula doing something similar that we use in the formula field to set a Date on a workflow action not scripted. CASE WHEN TO_CHAR({date},'D') = 1 THEN {today} WHEN TO_CHAR({date},'D') = 2 THEN {today}+1 WHEN TO_CHAR({date},'D') = 3 THEN {today}+2 WHEN TO_CHAR({date},'D') = 4 THEN {today}+3 WHEN TO_CHAR({date},'D') = 5 THEN {today}+4 ELSE {today} END