In the Notification message of a workflow, how can I convert <% =Operation.TargetToSet["accountExpires"] %> into a human readable date?
- Products
- Solutions
- Resources
- Trials
- Support
- Partners
- Communities
In the Notification message of a workflow, how can I convert <% =Operation.TargetToSet["accountExpires"] %> into a human readable date?
Hi, Ryan.
You can use the .NET DateTime::FromFileTime() method in notification C# code. Unfortunately I don't have an example at my disposal, but it's going to look something like this (untested/verified code):
DateTime accountExpiration = DateTime.FromFileTime(Operation.TargetToSet["accountExpires"])
Hope that's a starting point for you!
Shawn.
Shawn,
I tried that but I get some odd errors.
: error CS1502: The best overloaded method match for 'System.DateTime.FromFileTime(long)' has some invalid arguments
: error CS1503: Argument 1: cannot convert from 'string' to 'long'
I've tried to use Convert.ToInt64, but doesn't seem to help much :/
I just tried the following, and it seemed to work for me:
<%=DateTime.FromFileTime(Convert.ToInt64(Operation.Target["accountExpires"]))%>
Let me know if that helps!
Cheers,
Shawn.
EDIT: Note that this will generate an error when attempting to preview the message since Convert will throw an error since Operation.Target["accountExpires"] returns null/empty in the preview.
FWIW, a technique I have used is to store the date in human readable form in a VA and reference that in the notification instead.
Is it possible to intercept this error with an if-query? (if the attribute is not filled)