How do I write a " If-condition " in a projection script in Taleo Connect Client - taleo-connect-client

I need to write an IF condition within the Taleo Connect client, something like the following pseudocode:
IF
actual start date > Current
THEN
Retrieve Current date
ELSE
Retrieve actual start date
END

Appreciate this is long after the fact; but TCC is something i'm learning so in the hope it helps someone in teh future. I had to fix a date of Birth as a number of people had dates of Birth in the 3rd century for some reason.
This query worked to fix the date of birth to blank. This works fine.
<quer:projection alias="DATE_OF_BIRTH" projectedValueType="string">
<quer:switchByCriterion>
<quer:cases>
<quer:case>
<quer:greaterThanOrEqual>
<quer:field path="Birthday"/>
<quer:date>1901-01-01</quer:date>
</quer:greaterThanOrEqual>
<quer:customFunction name="TO_CHAR">
<quer:field path="Birthday"/>
<quer:string>yyyy-MM-dd</quer:string>
</quer:customFunction>
</quer:case>
</quer:cases>
<quer:defaultValue>
<quer:string> </quer:string>
</quer:defaultValue>
</quer:switchByCriterion>
</quer:projection>
This is my suggested solution based on the query above
<quer:projection alias="StartDate" >
<quer:switchByCriterion>
<quer:cases>
<quer:case>
<quer:greaterThan>
<quer:field path="actual start date"/>
<quer:date type="now"/>
</quer:greaterThan>
<quer:date type="now"/>
</quer:customFunction>
</quer:case>
</quer:cases>
<quer:defaultValue>
<quer:field path="actual start date"/>
</quer:defaultValue>
</quer:switchByCriterion>
</quer:projection>

Related

moment().startOf('day')` shows as `Moment<2020-05-01T00:00:00+02:00>`

Why moment().startOf('day') shows as Moment<2020-05-01T00:00:00+02:00>, in Nodejs ??
I want to show the date only, how to get the date only without Moment word and < > symbols.. !
So startOf() returns a moment object, what you're wanting to do is some kind of format of the output object.
console.log(moment()
.endOf('day')
.toISOString()) // 2020-05-18T21:59:59.999Z

Why does new Date(year,month,day) not return an equivialent Date?

one day I fiddled with vanilla NodeJS using the node command line tool. (I am using node v13.11.0)
I tried to create a new Date at the 01.01.1970. I used the usual new Date(year, month, day) constructor.
As simple as it sounds, I entered new Date(1970, 1, 1) and found out, that it does not return 1970-01-01T00:00:00.0000Z. Instead, it returns 1970-01-31T12:00:00.000Z.
Has anyone an Idea, why this constructor does not return the equivalent date?
The constructor does more or less what you think:
x = new Date(1970,1,1)
1970-01-31T14:00:00.000Z
> x.getMonth()
1
> x.getDate()
1
> x.getHours()
0
(Note that months count from zero, so you requested the 1st of February).
But if you display the whole date as a string, it's showing the time in UTC, which might not be what you expect.

IF statement to determine date

I want to set an order completion date based on the words Standard or Rush.
Currently I have it set up where if a cell shows the word Standard, it will give me a date, but once I try to add Rush to that, it get errors
=IF(ISNUMBER(SEARCH("VF",B2)), IF(J2="Standard", WORKDAY(TODAY( )+2,1)), "")
I also tried this, but when I type Rush into J2, the result shows as just FALSE
=IF(ISNUMBER(SEARCH("VF",B2)), (IF(J2="Standard", WORKDAY(TODAY( )+2,1))), (IF(J2="Rush", WORKDAY(TODAY( )+1,1))))
The idea here is to make an order wanted date based on the Rush and Standard time frame.
You have embedded your new IF function inside of the wrong if.
This: (IF(J2="Standard", WORKDAY(TODAY( )+2,1))) is going to return a date or FALSE. You want to change that FALSE to return your next IF statement. Instead:
=IF(ISNUMBER(SEARCH("VF",B2)), IF(J2="Standard", WORKDAY(TODAY( )+2,1), IF(J2="Rush", WORKDAY(TODAY( )+1,1))), "")
You return nothing "" in the case that your ISNUMBER() fails still.

Moment.js sets dates to 1 day behind

I am using 2.22.1 to format dates.
When i put in a date that comes from a date selector, moment will put the date back one day. For example, when I try to format a date in the following way:
Example 1:
const day = new Date(value).getDate();
const month = new Date(value).getMonth();
const fullYear = new Date(value).getFullYear();
console.log('day', day); // 7
console.log('month', month); // 5
console.log('fullYear', fullYear); //2018
Formatting function:
moment.utc(new Date(month + ' ' + day + ' ' + fullYear), 'MM-DD-YYYY').format('DD-MM-YY')
Output: 06-05-18
Expected: 07-05-18
Example 2:
Input: Thu May 31 2018 00:00:00 GMT+0100 (GMT Summer Time)
Formatting function:
moment.utc(new Date(value)).format('DD-MM-YY')
Output: 30-05-18
Expected: 31-05-18
moment.utc will convert the input to universal time.
You are running new Date(...) with an input that's based on GMT +1.
If you think about this, it makes total sense.
Your output is 30-05-18, because it's 11 PM / 23:00 o'clock on the previous day.
This (how ever) would in fact work:
moment('05-06-2018', 'MM-DD-YYYY').format('DD-MM-YY')
// alternatively (and preferrably) this:
moment.utc('05-06-2018', 'MM-DD-YYYY').format('DD-MM-YY')
and output: "06-05-18"
Because the non utc version does not take a time input in this example.
One of the reasons moment.js exists, is to get rid of Date in your code all together.
(Keep in mind tho, that Date has drastically improved now. DateTimeFormat is a game changer)
Please just read the momentjs documentation on how to properly use moment.
edit:
If you want to process 400000 dates with this, I'd advise using RegExp, .split, .exec, .slice or Date instead.
(I can relate since I wrote a client sided Log parser with javascript generators and Service Workers for a statistical anti-cheat analysis)
I truly recommend playing around with such things to raise your knowledge.
I just ran into this issue and a quick fix I found for the time being processed in "Zulu time" (due to the Z at the end of the string) is to add .LocaleString() after the date variable.
I find that for data consistency, it's easier to store data in UTC time and then convert it to the locale string when displaying the data to the user.
For example, I'm using:
moment.utc(dateVariable.toLocaleString()).format("MM/DD/YYYY")

AwesomeWM time not updating?

I'm using AwesomeWM, and I'm trying to display the time in my wibox using this code
vicious.register(datewidget, vicious.widgets.date, os.date("%b ")..(os.date("%d")+0).. ', ' ..(os.date("%I")+0)..os.date(":%M")..string.lower( os.date(" %p ")), 1)
The time is correct when I open AwesomeWM, but it doesn't update. For whatever reason , 1) doesn't work.
heres my full rc.lua
I guess the problem is with what the register function expects. It expects a format string with which it can calculate date itself. Here you're passing a literal string instead of formatting parameters.
From your older question, I found a different method for the same. Now, your vicious need to be like:
vicious.register(datewidget, vicious.widgets.date, "<span font-family='terminus' color='#999999'>%b %d, %l:%M %P</span>", 1)
And it should work.
P.S. Thanks to sa1

Resources