Skip to main content
Nintex Community Menu Bar
Question

invalid js date from sf field after parseSFDate?!?!

  • July 9, 2024
  • 9 replies
  • 19 views

Forum|alt.badge.img+20

It’s all in the pic.
c5e4697151e8ed26bfb2f01a8afb106bdfd668bd.png

This topic has been closed for replies.

9 replies

Forum|alt.badge.img+4

Interesting… Maybe give skuid.time.parseSFDateTime a shot


Forum|alt.badge.img+20

Weird I know. I’ll try it, but the SF field is type Date. Shouldn’t work. One sec.


Forum|alt.badge.img+20

Returns false. Love Chrome developer tools! Starting to get a hang of the errors.


Forum|alt.badge.img+20

Here’s a video of me unsuccessfully trying to use the date objects. 



Forum|alt.badge.img+11

Pat.

just a cursory look, but notice that your formula field returns a Date.  The parseSFDate function takes a Salesforce Date string.   Hope this helps.


parseSFDate( sfDate )

Takes a Salesforce Date string and converts it to a JavaScript Date object

PARAMETERS:

  • sfDate (string): A Salesforce date string

RETURNS:

Date

The corresponding JavaScript Date object














Forum|alt.badge.img+20

Found a post saying that this is to be expected.
http://stackoverflow.com/questions/9725299/why-does-chrome-dev-tool-show-a-dates-proto-as-invalid-date


So then my coding approach was the issue. I was trying to compare one object to another object. By definition, no two objects can ever be equal. I was really supposed to compare the values in the object. At least that’s my thinking. Let me know otherwise.

So I instead I set the vars to strings using toISOString(). Now it works. 😃


Forum|alt.badge.img+11

Good to hear.  Happy coding.


Forum|alt.badge.img+20

Happy is one word for it.


Forum|alt.badge.img+13

Pat here is a good post about doing comparisons with Dates in JavaScript. If you just want to do > or < checks, then comparing the straight JavaScript Date objects as returned by skuid.time.parseSFDate() or skuid.time.parseSFDateTime() would be fine, e.g. 

skuid.time.parseSFDate(sfDate1) < skuid.time.parseSFDate(sfDate2)

But for testing equality it is not as easy as doing == or ===, you need to compare either the getTime() values for each Date or subtract the dates from each other and see whether the result === 0.