APIs & Integrations

EddBrisley
Contributor

Copying custom date values to date property error

SOLVE

Interesting one today! 

 

I've got a workflow with a custom code element which retrives the hs_timestamp value (in the format '2024-01-10T16:00:00Z'), and that all works fine. 

 

Up until about April, I was able to successfully copy this datetime output to a date property within the workflow. However! it then started generating the error for seemingly no reason: 

"Unable to update property because property value isn't valid"

 

I've tried converting the timestamp value into a unix value, but no cigar. 

 

Anyone have any idea as to what caused this change, and if there are any solutions/alternatives?

 

Many thanks in advance crew 🙂 

 

0 Upvotes
1 Accepted solution
KimM
Solution
Top Contributor

Copying custom date values to date property error

SOLVE

I actually built a workflow the other day and ran into this issue.

 

Couple of things I noted:

  • When copying the date or date/time properties that you've fetched via an API call you must convert to a date object and then getTime() for the millisecond timestamp
  • If you're copying this value to a date property (not a date time property) you have to set the hours, minutes, seconds and milliseconds to 0. It will only accept round dates, even if in millisecond timestamps.

Below is a code sample of how I went about this:

timestamp = apiResponse.results[0]["properties"]["hs_timestamp"];
const dateObject = new Date(timestamp);
dateObject.setUTCHours(0, 0, 0, 0);
timestamp = dateObject.getTime();

I was specifically using the results from an API call, so need to convert it to a date object first to be able to manipulate it.

 

Hope this helps.

View solution in original post

3 Replies 3
KimM
Solution
Top Contributor

Copying custom date values to date property error

SOLVE

I actually built a workflow the other day and ran into this issue.

 

Couple of things I noted:

  • When copying the date or date/time properties that you've fetched via an API call you must convert to a date object and then getTime() for the millisecond timestamp
  • If you're copying this value to a date property (not a date time property) you have to set the hours, minutes, seconds and milliseconds to 0. It will only accept round dates, even if in millisecond timestamps.

Below is a code sample of how I went about this:

timestamp = apiResponse.results[0]["properties"]["hs_timestamp"];
const dateObject = new Date(timestamp);
dateObject.setUTCHours(0, 0, 0, 0);
timestamp = dateObject.getTime();

I was specifically using the results from an API call, so need to convert it to a date object first to be able to manipulate it.

 

Hope this helps.

EddBrisley
Contributor

Copying custom date values to date property error

SOLVE

Hi @SteveHTM , thanks for your response. 

 

I've just tested with the extra decimal place, and that doesn't seem to be it. Thanks anyway, I'll keep digging, if I find out what's up I'll post here 👍

0 Upvotes
SteveHTM
Guide | Partner
Guide | Partner

Copying custom date values to date property error

SOLVE

@EddBrisley - I don't know how picky the format conversions are, but I ended up using date stamp values formatted as "%Y-%m-%dT%H:%M:00.000Z" - looks like there is an extra decimal place usage vs your reported format.

 

I don't have any insight into what may have changed recently with date handling.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature