You are viewing limited content. For full access, please sign in.

Question

Question

how to write a date into a lookup table with workflow? format token?

asked on May 6, 2024

Working in Cloud, date passed from modern form into workflow and attempting to insert as a datetime into a lookup table. Getting cast error.  Is there a token format that works to insert dates, tried  #yyyy-MM-dd#, g, G,O but nothing seems to work? I'm going to change the lookup table to a string for now but would like to know how to accomplish this as a date format.

 

date comes in from BP to workflow as 5/3/2013 12:00:00 AM (UTC-06:00)

O is giving 2013-05-03T00:00:00.0000000+00:00

the date in the lookup table is formatted 2014-01-26T00:00:00Z

i'm going to try "u" next before switching back to a string

0 0

Answer

SELECTED ANSWER
replied on June 3, 2024 Show version history

Hello Steve,

I encountered a similar issue when trying to insert a date field into a lookup table. The insertion works fine as long as a date value is provided, but an error occurs (Can't cast value to type System.DateTime.) when the date value is blank.

Use a condition to sort the blank/Null value.

Date formatting that I used:

You can ignore the regular expression - extracting the value from using API request

0 0

Replies

replied on May 6, 2024

Actually, now i test some more i don't think the issue was the date. it'd be real handy if the error logging was more specific. It doesn't say what the bad values field is, just "Can't cast value to type System.Int32." but what value? where?

0 0
replied on May 7, 2024

Do you have a value in your table that is set to Integer, that maybe you are trying to put something other than numbers into?

0 0
replied on May 7, 2024

The datatype in the table was datetime but i could not insert that with workflow.

I ended up switching the datatype to text, then using a token calculation activity to TEXT(DoB) and format a "u" and that ultimately worked, except the date is stored as text now. I'd like to know if anyone else has been able to write dates to lookup tables and if they used token formatting, adding the additional activity for token calculation does add an additional activity that we'd ideally like to avoid.

The other thing is the error message does not mention what format is wrong, in which field. I;m assuming it was the date but there are many fields it might have been complaining about, it's a guessing game with such a generic error.

 

0 0
SELECTED ANSWER
replied on June 3, 2024 Show version history

Hello Steve,

I encountered a similar issue when trying to insert a date field into a lookup table. The insertion works fine as long as a date value is provided, but an error occurs (Can't cast value to type System.DateTime.) when the date value is blank.

Use a condition to sort the blank/Null value.

Date formatting that I used:

You can ignore the regular expression - extracting the value from using API request

0 0
replied on January 2

this post has me scratching my head Bipin, the screenshot shows dd-MM-yyyy formatting and that's not what i expected.

0 0
replied on June 3, 2024

I think i know what happens here in my case, say you set up a lookup table and load some data. At the time of import the table sets the datatype.

Then create a rule and plug that into a workflow and test only to find CAST error. But where is it, it doesn't say... So trial and error, go back to the table and reimport the data, changing the suspicious datatypes maybe from number or date to text - this is where an invisible issue can arise.

Inside the rule, the data is not visibly typed - i can see nothing to say if the data is a number or a string however i believe it holds on to the type when the rule was created.  Updating the table does not cause it to refresh.  The solution is simple, remove all the select and where clauses and add them back in again to rebuild the rule.  That seemed to fix the issue for me. 

0 0
replied on January 2

I'm having trouble with a function in Laserfiche that seems to be giving me persistent issues. I have a business process (BP) with a table containing dates, which are passed to a workflow via a dateTime parameter (e.g., 12/30/2024 12:00:00 AM, 12/30/2024 12:00:00 AM). However, when the workflow inserts the date into a dateTime formatted column in a lookup table, I get a cast error.

I’ve tried using the token calculator with datevalue(12/30/2024 12:00:00 AM), but it doesn’t work. I also tried parsing the date to extract the year, month, and day, and then using date(vYear, vMonth, vDay). This works in the token editor but fails during runtime.

Why is it so difficult to pass a Laserfiche date between its own modules without needing conversions? I’m working entirely within Laserfiche and simply trying to pass a date from one module to the next. Can anyone shed light on why this might be happening, is it regionals settings?

 

0 0
replied on January 2

When i extract the year, month, day im using regex that works on the date as its written in the token (12/30/2024 12:00:00 AM) but at run time I'm getting a date (1,1,1) so its writing in a date from 1899. At least the cast error has gone but I'm suspecting the date displayed in the BP and WF token is displayed human readable, but its stored/processes as a datetime. My regex works on the date string but fails at run-time so if the "date is a date" then why the cast error inserting into a lookup table?

 

0 0
replied on January 2

Got it! Bipin's post got me there. Look in the rule, test it and see that it's expecting a date 'yyyy-MM-dd' so in the Workflow rule activity just add that formatting there and it works great.  Here is a screen shot to show. 

formatDates.jpg
formatDates.jpg (608.06 KB)
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.